Concatenating Mixed numbers looses the decimal places

조회 수: 3 (최근 30일)
Jason
Jason 2024년 9월 25일
댓글: Jason 2024년 9월 25일
Hi, I have some numbers that I want to concatenate and add to a uitable. I've noticed that although the individual numbers have decimal places, the concatenation seems to remove the decimal values.
n
MaxI
MinI
medianMaxIntensity
Hlg
fwhm2D
Bren
A=[n,MaxI,MinI,medianMaxIntensity, Hlg,Bren,fwhm2D]
%-----------------------------------------------------------
n =
405
MaxI =
uint16
168
MinI =
uint16
36
medianMaxIntensity =
126
Hlg =
3.7750
fwhm2D =
4.1606
Bren =
56.1112
A =
405 168 36 126 4 56 4
How can I retain the decimal numbers (I only want 2 decimal places, so will use:)
uit.ColumnFormat= {'bank','bank','bank','bank','bank','bank','bank'};
Thanks
Jason

채택된 답변

Stephen23
Stephen23 2024년 9월 25일
편집: Stephen23 2024년 9월 25일
"How can I retain the decimal numbers "
A = [n,double([MaxI,MinI]),medianMaxIntensity, Hlg,Bren,fwhm2D];
% ^^^^^^^^ ^^
or
A = [n,double(MaxI),double(MinI),medianMaxIntensity, Hlg,Bren,fwhm2D];
% ^^^^^^^ ^ ^^^^^^^ ^
Explanation:
  댓글 수: 1
Jason
Jason 2024년 9월 25일
Thanks, I have just read this - I didnt know about this at all.
https://uk.mathworks.com/help/matlab/matlab_oop/concatenating-objects-of-different-classes.html
MATLAB Concatenation Rules
MATLAB® follows these rules for concatenating objects:
  • MATLAB always attempts to convert all objects to the dominant class.
  • User-defined classes take precedence over built-in classes like double.
  • If there is no defined dominance relationship between any two objects, then the leftmost object dominates (see Class Precedence).

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by