Analysis error with input timetables
Ältere Kommentare anzeigen
Why I am getting error:
Error using timetable/retime
All variables in input timetables must be numeric, datetime, or duration when synchronizing using 'mean'.
Error in ko - 1h avg to new channel (line 10)
avgdata=retime(data,'regular','mean','TimeStep',hours(hourz));
DATA EXPORT CSV LOOKS LIKE:
2023-01-21T23:47:13+02:00 45161 533 23.187 29.27 18.23 18.61 -8.5 93 -10
CODE ko - 1h avg:
dayz=1;
hourz=1;
rc=1234;
rk='KEY';
wc=5678;
wk='KEY';
data=thingSpeakRead(rc,'ReadKey',rk,'OutputFormat','timetable','numDays',dayz);
avgdata=retime(data,'regular','mean','TimeStep',hours(hourz));
thingSpeakWrite(wc,avgdata,'WriteKey',wk);
3 Kommentare
Christopher Stapels
am 22 Jan. 2023
Perhaps look at the datetime. MATLAB might not know the format if you arent telling it.
try
datetime('2023-01-21T23:47:13+02:00')
and see if you get a date time object back. I think you will have to reformat that column in your data and tell MATLAB the format you are using.
Walter Roberson
am 22 Jan. 2023
Bearbeitet: Walter Roberson
am 28 Jan. 2023
The T is the main problem. The default formats do not support the time zone offset field but you can specify XXX as an input format to code for that. There is no direct code for the T however. You have to code 'T' for that where the apostrophes are part of the syntax. For example "uuuu-MM-dd'T'HH:mm:ssxxx"
Notice the use of " to make it easier to code the literal ' characters
Antworten (0)
Communitys
Weitere Antworten in ThingSpeak Community
Kategorien
Mehr zu Time Series Collections finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!