Can I add units to the table?

161 ビュー (過去 30 日間)
Diego Guarachi
Diego Guarachi 2019 年 5 月 17 日
コメント済み: Lorenzo Chiaverini 2021 年 1 月 21 日
Can I add units to the variables in the table? I have searched for information and I could not find anything, it can only be done in numbers ...please help
  2 件のコメント
Matthew Anderson
Matthew Anderson 2020 年 4 月 9 日
Agree, super annoying that when you put units into a table - they aren't displayed.
Lorenzo Chiaverini
Lorenzo Chiaverini 2021 年 1 月 21 日
Idem, it would be great if they were displayed as you showed

サインインしてコメントする。

回答 (2 件)

Raj
Raj 2019 年 5 月 17 日
"Can I add units to the variables in the table?" Yes you can. You can specify units for each variable in the table by modifying the table property,
% |VariableUnits|.
Specify the variable units as a cell array of character vectors.
Something like this:
table (W,T,Pe,P)
T.Properties.VariableUnits = {'Rad/S','NM','N','N'}; % what I could make out from your picture. Please correct if wrong.
Or Do you want the units to get displayed on your table? Please be clear.
  8 件のコメント
Andreas Lobinger
Andreas Lobinger 2020 年 12 月 15 日
I see - and thanks for the long explaination. Can you provide a "why" here? I'd assume a lot of researchers want to put units in tables - and adding to the variable name eats up screen space, so a second line looks like the natural solution.
Walter Roberson
Walter Roberson 2020 年 12 月 15 日
table() are not designed for presentation purposes. Report Generator has facilities for better output of tables.
That said, it would seem to me to be a small thing to add the units or the Variable Description information (which might be the original names of the variables.) It could even be made into properties as to whether to display them or not. I don't know why Mathworks has not done this.
table() could also benefit from a per-variable format specification... among other things.

サインインしてコメントする。


KSSV
KSSV 2019 年 5 月 17 日
It is not allowed...may be you can use something like this:
varNames = {'Name', 'Age_in_Years'} ;
varTypes = {'string','double'};
s = {'Tom' ; 'Dick' ; 'Hary'} ;
a = [20 ;21; 24] ;
T = table(s,a) ;
T.Properties.VariableNames = varNames

カテゴリ

Help Center および File ExchangeTables についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by