Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Can I update the units/properties of a time table using the head function?

1 vue (au cours des 30 derniers jours)
ZH
ZH le 22 Juil 2020
Clôturé : MATLAB Answer Bot le 20 Août 2021
Instead of listing off each variable unit,
TT.Properties.VariableUnits = {'','C','kW','kW','Auxiliary','Auxiliary','Auxiliary','W','W','C'};
I am trying to grab each unit from the first header grabbed
Units = head(TT,1)
^^ then implement that into the variablunits??
Something is off on my end.
  3 commentaires
ZH
ZH le 23 Juil 2020
Understood. Is there a way to change the properties to the first row of TT? Or do I have to list them out?
Star Strider
Star Strider le 23 Juil 2020
The first row of the ‘TT’ table is likely data, do you can do anything with them that you want to (within limits).
If you want to change the variable names or units, you can address them individually (since they are cell arrays) to change any one or more of them. You would have to use the appropriate ‘TT.Properties.’ structure regardless.

Réponses (1)

Cris LaPierre
Cris LaPierre le 23 Juil 2020
If you are asking if MATLAB can automatically extract units from the column name (e.g. Time (mins)), the answer is no. You would have to write the code yourself to separate the two and then add the units to the table property.
You can set up your data file in a way that would allow MATLAB to read in your units automatically. The units would need to be on their own row. You would then need to set up import options by telling it which row contains the units. See here (for a spreadsheet).

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by