How do you name time series / table variables?

38 views (last 30 days)
Hello community,
when having a dataset with much variables in the form of a timetable, I often name the table with its variables something like:
However it happens quite often, that I have a time series in the form of a timetable, which only is made from one measurement.
This makes me always wondering how I should call those variables, since I dont want the timetable be called "Data".
At the moment I am using mostly something like:
Temperature.Values % Temperature.Value? Temperature.Data? Temperature.temperature??? I hate it.
How would you name souch a timetable?
There is no "right" answer here, so my favorite one after a day or so will be accepted :)
dpb on 6 Feb 2021
Edited: dpb on 7 Feb 2021
"I want to know what the MATLAB guidelines are."
There aren't any...the best you can do is see what the default naming convention is in any given place -- for a table or timetable, it's a capitalized name string.

Sign in to comment.

Accepted Answer

Steven Lord
Steven Lord on 6 Feb 2021
My advice is to name the variable that contains your timetable array something that makes sense for your application. If you're using a timetable to store the temperature measured at (for example) Boston's Logan Airport then an appropriate name might be airportTemp or Logan or even just temperatures (especially if the timetable has entries for other locations along with a variable stating where the measurements were taken.) Similarly the names of the variables in your timetable should make sense for your application. If I had that timetable of Logan Airport temperature measurements any of F (for Fahrenheit), Temp, or measurement might be appropriate names for that variable.
Don't read too much into the default name for the time dimension being Time instead of time. The name refers to time because this is a timetable not a table. And if you specify a different variable name as the times of your timetable the first dimension name may be different. Using the example from the timetable help text:
MeasurementTime = datetime({'2015-12-18 08:03:05';'2015-12-18 10:03:17';'2015-12-18 12:03:13'});
Temp = [37.3;39.1;42.3];
Pressure = [30.1;30.03;29.9];
WindSpeed = [13.4;6.5;7.3];
WindDirection = categorical({'NW';'N';'NW'});
TT = timetable(MeasurementTime,Temp,Pressure,WindSpeed,WindDirection)
TT = 3x4 timetable
MeasurementTime Temp Pressure WindSpeed WindDirection ____________________ ____ ________ _________ _____________ 18-Dec-2015 08:03:05 37.3 30.1 13.4 NW 18-Dec-2015 10:03:17 39.1 30.03 6.5 N 18-Dec-2015 12:03:13 42.3 29.9 7.3 NW
ans =
TimetableProperties with properties: Description: '' UserData: [] DimensionNames: {'MeasurementTime' 'Variables'} VariableNames: {'Temp' 'Pressure' 'WindSpeed' 'WindDirection'} VariableDescriptions: {} VariableUnits: {} VariableContinuity: [] RowTimes: [3×1 datetime] StartTime: 18-Dec-2015 08:03:05 SampleRate: NaN TimeStep: NaN CustomProperties: No custom properties are set. Use addprop and rmprop to modify CustomProperties.
The first dimension is MeasurementTime not Time. The error message you receive if you ask TT for its time data makes this clear.
ans = 3×1 datetime array
18-Dec-2015 08:03:05 18-Dec-2015 10:03:17 18-Dec-2015 12:03:13
TT.Time % will not work
Unrecognized timetable variable name 'Time'. If you intended to access the row times, use 'MeasurementTime' for this timetable instead.
dpb on 6 Feb 2021
"... let's say I don't want combine them. How should I name the timetables and its variables?"
Again, w/o more details of what you're going to be doing with them, if it really is reasonable to not combine tables, I'd suggest an array of tables would be a practical solution to solve both naming problems of what the table(s) are named as well as the internal variable(s).
Personally, given my preference for coding style, I'd almost certainly combine the tables unless the times are inconsistent and there never will be a wish to synchronize them but treat them all as totally independent.

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!