format number column table/array

24 次查看(过去 30 天)
just as an example, in Microsoft Excel, we can format any cell of spreadsheet or an entire column, chosing how many digits will appear after decimal point, or using comma separator.
I need to read my table without lots of digits after point in some columns, and other columns just entire part of number with comma separator.
I dont have doc generator package and dont need a word/pdf report.
If is possible to format columns in a simple array as well, I would like to know how.
Thanks!

回答(1 个)

Walter Roberson
Walter Roberson 2023-11-8
MATLAB does not provide any way to customize how many digits are displayed for numeric arrays, other than 2 digits ( format bank ) or 5 digits in scientific notation ( format short e ) or 16 digits in scientific notation ( format long e )
MATLAB does not provide any method to customize how many digits are displayed for numeric arrays in uitable for traditional figures or for uifigure, other than the ability to chose a format on a per-column basis.
You cannot, for example, customize to say use non-scientific notation with 3 decimal places.
You can define formatting rules for your own class, https://www.mathworks.com/help/matlab/ref/matlab.mixin.customdisplay-class.html
Also, I am unclear at the moment about how much it is possible to do if you were to attach a uistyle to a uitable in a uifigure -- but as far as I have seen so far I have not seen a way to customize numeric display format using that approach.
  2 个评论
Walter Roberson
Walter Roberson 2023-11-8
The usual work-around is to round() values to be put into a uitable . or to use compose to convert the numeric values into string arrays to be put into the uitable (possibly then converting them to categorical ) .
Do you need an editable uitable, so the user can modify the values in the interface, and the values the user puts in have to be forced to follow the formatting rules too?
Andre Carvalho
Andre Carvalho 2023-11-8
First of all, Walter, thank you so much for the clear explanations!
About editable uitable, I dont need this. Anyway, in help documentation I saw a callback function example that update the uifigure when change the data.
Thanks again!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Maintain or Transition figure-Based Apps 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by