Jichao Fang in Discussions
Letzte Aktivitätam 13 Nov. 2021

I have both of my account profile and channel export time zones set to "(GMT+8000)Beijing". The datetime from the exported feeds.csv looks like: '2021-09-06 11:16:28 CST' I want to import data, but MATLAB do not directly understand its datetime format. I assume "CST" to be "China Standard Time", but when I try to convert it to datetime, MATLAB throws an error: >> datetime(s,'InputFormat',"yyyy-MM-dd HH:mm:ss z","TimeZone","Asia/Shanghai","Locale","zh_CN") Error using datetime (line 651) Unable to convert '2021-09-06 11:16:28 JST' to datetime using the format 'yyyy-MM-dd HH:mm:ss z' and locale 'zh_CN'. However if I change the "Locale" to US instead: >>datetime(s,'InputFormat',"yyyy-MM-dd HH:mm:ss z","TimeZone","Asia/Shanghai","Locale","en_US") ans = datetime 07-Sep-2021 01:16:28 There is no error, but the time is wrong and is 14 hours ahead. So I guess that MATLAB sees this "CST" as "Central Standard Time". My point is: # It's pretty strange that the datetime exported by ThingSpeak could not be directly understood by MATLAB. MATLAB is supposed to work with ThingSpeak data seamlessly, but now I have to find a detour to import ThingSpeak data to MATLAB. # It seems that the datetime function needs improvement to understand this "CST" timezone, or that ThingSpeak could improve its datetime output format. Handling datetime from exported csv file Thank you for sharing. That is good feedback. We'll update the export functionality to return the timestamps as ISO8601 format so it can be read in to MATLAB easily. Thanks for the reply! Definitely looking forward to it. We made an update earlier in the week that results in the data exported from a channel to be in ISO8601 format. The exported file can easily be imported back to a ThingSpeak channel, if you need to manually clear some bad data in a channel. It is also really simple now to import the exported CSV into MATLAB using code like this: table = readtable('feeds.csv') table.created_at = datetime(table.created_at, 'InputFormat', 'yyyy-MM-dd''T''HH:mm:ssXXX', 'TimeZone','UTC') data = table2timetable(table) Thank you! Now it's easier than ever to work with the data. datetime export
Samee Imtiyaz in MATLAB Answers
Letzte Aktivitätam 12 Jul. 2021

I am using datetime('now') to get the current time in my matlab analysis app code. However, it returns the datetime variable in 12 hour time without an AM/PM. In my code I am using isbetween to check whether the current time is within a range althought this range is in 24H time. Is there any way to change the datetime('now') in the matlab analysis app on thingSpeak to 24H time as it gives me 24H time format when I try on the normal matlab console.
Mars Rap in MATLAB Answers
Letzte Aktivitätam 9 Jun. 2020

I have a CSV generated from ThingSpeak, which contains a datetime containing a time zone identifier (CEST in my case). It looks like this: created_at,entry_id,field1,field2,field3,latitude,longitude,elevation,status 2020-06-06 18:36:17 CEST,1,434,2.12121212121,30.3487192708,,,, 2020-06-06 18:36:33 CEST,2,433,2.11632453568,30.2823285934,,,, 2020-06-06 18:36:48 CEST,3,436,2.13098729228,30.4815006257,,,, 2020-06-06 18:37:03 CEST,4,433,2.11632453568,30.2823285934,,,, Now, when I edit the file and remove " CEST" from all rows, readtimetable imports the file properly, with no issues. But when I leave it as is, readtable imports the field as text, while readtimetable refuses altogether. I tried to specify the format manually, as so: opts.VariableNames = ["created_at", "Var2", "field1", "Var4", "Var5", "Var6", "Var7", "Var8", "Var9"]; opts.SelectedVariableNames = ["created_at", "field1"]; opts.VariableTypes = ["datetime", "string", "double", "string", "string", "string", "string", "string", "string"]; opts = setvaropts(opts, "created_at", "InputFormat", "dd-MM-yyyy HH:mm:ss z", "TimeZone", 'Europe/Warsaw'); With this, readtimetable works but... all fields are turned into NaT. Now, this is some weird behavior, because using the datetime function with one of those fields copied works flawlessly: >> date = datetime("2020-06-06 18:36:17 CEST","InputFormat","yyyy-MM-dd HH:mm:ss z","TimeZone","Europe/Warsaw") date = datetime 06-Jun-2020 18:36:17 Matlab's importer also can't handle it, when I use the CSV file as the input it wrongly detects the delimiter, once that's corrected and field type set to datetime, any way I tried configuring the input format just fails and results in NaTs. I even attempted to set the format to "yyyy-MM-dd HH:mm:ss 'CEST'", so the time zone gets treated as a string, but it still fails to recognize it as a correct datetime. Using Matlab R2020a
black in MATLAB Answers
Letzte Aktivitätam 22 Sep. 2019

I want to label the time axis in a plot with "ddd: HH" (speak "first three letters of the day, then the two digits for the hour in 24-hour format). However, when doing this, the format is applied for some labels, but otheres also print more information like month, day and year. % generate time sequence, last 3 days, 12 hours offset xtickformat('eee: HH') t2 = datetime('today'), t1 = t2-days(3) xData = t1:hours(12):t2 set(gca,'xtick',xData) Leads to:

Info zu ThingSpeak

The community for students, researchers, and engineers looking to use MATLAB, Simulink, and ThingSpeak for Internet of Things applications. You can find the latest ThingSpeak news, tutorials to jump-start your next IoT project, and a forum to engage in a discussion on your latest cloud-based project. You can see answers to problems other users have solved and share how you solved a problem.