Concatenating Mixed numbers looses the decimal places

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Stephen23
Stephen23 il 25 Set 2024
Modificato: Stephen23 il 25 Set 2024
"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 Commento
Jason
Jason il 25 Set 2024
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).

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by