How to read units from a column in a table in Matlab?

I read in a csv into a table and set each column's units with VariableUnits. I would like to be able to read the units for a certain column (say column 3, "Temp"). I would like to know if the temperature was recorded in degrees F or C or K.
I can use table{1,1}.Properties.VariableUnits to display the units for all the columns, but I can't figure out how to look up the units for just one column.
Also if I want to update the units for one column, how can I do that as well?

답변 (2개)

Jason Burke
Jason Burke 2021년 5월 17일
I figured out that calling the column at the end of the statement is the way to reference the column.
table{1,1}.Properties.VariableUnits{column_name}
Is the way to get the column information.

댓글 수: 1

Joshua
Joshua 2026년 7월 23일
편집: Joshua 2026년 7월 23일
Thanks for this! Just what I needed. Did you find this out from reading documentation or trial and error? I haven't seen it written down anywhere that you can do this!
However, I can't seem to get this to work when there are multiple column_names to index at once. For example:
table{1,1}.Properties.VariableUnits{["var1" "var3"]}
The result returned seems to be that of the last indexed variable. In this example the unit of var3

댓글을 달려면 로그인하십시오.

Geoff Hayes
Geoff Hayes 2021년 5월 17일
Jason -
T.Properties.VariableUnits{2}
will get you the units for the second column.
T.Properties.VariableUnits{2} = 'NewUnit';
will update the unit name for that column.

카테고리

도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2021년 5월 17일

편집:

2026년 7월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by