Create new table wit differentiate or diff from existing timetable
20 次查看(过去 30 天)
显示 更早的评论
I've got below timetable with daily measurements from my gas meter at home:
Timestamps GasM3
____________________ _____________
14-Aug-2019 00:00:00 331.15
25-Aug-2019 00:00:00 332.37
26-Aug-2019 00:00:00 332.74
27-Aug-2019 00:00:00 333.97
I would like to know the daily consumption, so I tried playing with "differentiate" & "diff" to get these values in a new table.
I've tried
Test1 = differentiate(DailyGasDataTimeTable)
which gave the following error:
Error using Visualization: Differential test</a> (line 17</a>)
'differentiate' requires Curve Fitting Toolbox
and
Test2 = diff(DailyGasDataTimeTable)
which gave the following error:
Undefined function 'diff' for input arguments of type 'table'.
Error in Visualization: Differential test (line 17)
Unfortunately I'm stuck, please advise.
Kind regards,
Daniel
0 个评论
回答(4 个)
Kristina Collins
2020-8-31
What if my timetable is missing entries, or the entries are unevenly timed?
Olavo
2023-8-21
编辑:Walter Roberson
2023-8-21
Hello, Thanks for your answer it's very helpful!
What if I the variable I what to differentiate is not a fixed name and will be changing along the code? for example:
for i=1:10;
deltaM(i) = diff(data.GasM3{i}); % -->> does not work with this notation
end
3 个评论
Steven Lord
2023-8-21
Or you could use a numeric index.
T = array2table(magic(4))
A = T{:, 3} % Equivalent to T.Var3
If you're release R2023a or later, you may be able to compute directly on the table or timetable, as described on this documentation page.
T2 = diff(T)
Olavo
2023-8-22
Thanks Walter and Steven, very useful information.
Just to add some extra information, I found the function wildcardPattern very useful to get similar names from table. would be something like:
varname = "GasM3" + wildcardPattern;
社区
更多回答在 ThingSpeak Community
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 MATLAB Mobile Fundamentals 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!