Also why does MATLAB name the time "Time" and not "time"? The time is an array not a struct, and should be lowercase, shouldnt it?
How do you name time series / table variables?
37 views (last 30 days)
Show older comments
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:
Data.Time
Data.temperature
Data.current
etc...
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.Time
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 :)
14 Comments
dpb
on 6 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.
Accepted Answer
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.Properties
The first dimension is MeasurementTime not Time. The error message you receive if you ask TT for its time data makes this clear.
TT.MeasurementTime
TT.Time % will not work
6 Comments
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.
More Answers (0)
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!