Concatenating Mixed numbers looses the decimal places

3 visualizaciones (últimos 30 días)
Jason
Jason el 25 de Sept. de 2024
Comentada: Jason el 25 de Sept. de 2024
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

Respuesta aceptada

Stephen23
Stephen23 el 25 de Sept. de 2024
Editada: Stephen23 el 25 de Sept. de 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 comentario
Jason
Jason el 25 de Sept. de 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).

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by