Timetables not fully supported by plot tools?
24 views (last 30 days)
Show older comments
Hello,
I am just wondering why when plotting a timetable with duration as time axis, The "basic fitting" and "data statistics" tool in plot windos are not available.

Does this mean that timetables have some limitations compared to arrays or tables? I am asking because I need to decide if timetable is the right data structure for my use case. Basically I am importing some measuremet datas from sensors acquisition which have timestamps. In the past I would have just used plain arrays, but I see that in modern Matlab timetables are somehow suggested for these use cases.
0 Comments
Accepted Answer
dpb
about 3 hours ago
Moved: dpb
about 3 hours ago
The issue isn't with the timetable itself but in the extensions added to the plotting figure haven't been updated to include them. Never using those, I hadn't noticed .. I don't suppose the regular table is available, either.
There are some features such as retime that are only available with timetables that does make them handy for coding with, but if the interaction with the plot itself is a required feature, you'll have to use some other mechanism or extract the data from the timetable prior to plotting.
Would seem worthy of submitting an enhancement request...
2 Comments
dpb
22 minutes ago
"...[is] representing time domain signals is a "correct" usage of timetables?"
Well, given a timetable is a set of times with associated data to go with the observations, it appears intended to be used for precisely such things.
I would say it is more a question of what one intends to do with the data; if features specifically implemented for the timetable data class such as retime mentioned before would be helpful it would seem a reasonable fit.
OTOH, if we're talking about highspeed signal processing data acquisition kinds of application, it is probably not the ideal use case. There is another timeseries data class intended for sampled data although I've not found it convenient for my usage; there are features in it that may be of interest for certain tasks.
As for using with Simulink, I don't know a thing about it -- I'd guess interaction there would probably be simpler with simple arrays, but again I suspect it may matter as to what interaction is needed.
More Answers (1)
Steven Lord
about 2 hours ago
Let's say that with basic fitting, you wanted to fit a quadratic (y = a(1)*x^2+a(2)*x+a(3)) to your data. If the x data was double, this would be possible.
v = 0:5
y = polyval([1 2 3], v) % a would be [1 2 3]
A = polyfit(v, y, 2) % check that it is [1 2 3]
But with duration data for x, let's do a unit analysis. How would you add x^2 (with units of hours squared), x (with units of hours), and a constant together? I suppose you could make the constant a(1) be unitless, a(2) have units of hours, and a(3) have units of hours squared (which would require y to have units of hours squared) but then you couldn't store them all in one array.
In fact, the power operators aren't defined for duration data. Neither is the times operator where both operands are duration arrays. We don't let you make duration data with units of hours squared.
x = hours(v)
try
z = x.^2
catch ME
fprintf("Error: %s", ME.message)
end
x2 = hours([1 2; 3 4]);
try
z = x2^2
catch ME
fprintf("Error: %s", ME.message)
end
try
z = x.*x
catch ME
fprintf("Error: %s", ME.message)
end
So IMO it doesn't conceptually make sense to do basic fitting with date and time data.
The data statistics functionality could probably work with duration data. I haven't thought it completely through to identify any sticking points. My guess is that there haven't been (very many if any) requests for that tool to support datetime and duration data, so it hasn't been a priority.
3 Comments
dpb
10 minutes ago
I posted some thoughts on that topic above -- I agree that if it is classic signal processing, particularly with fixed-rate sampling the array is likely a better choice although as noted there, there is the specific timeseries data class as well although it seems oriented towards events handling.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!