Concatenating Mixed numbers looses the decimal places

2 ビュー (過去 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 Center および File ExchangeCreating 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