How to Display certain time period of data

25 ビュー (過去 30 日間)
Khalid Al naime
Khalid Al naime 2021 年 1 月 31 日
回答済み: Niall 2021 年 5 月 7 日
HI How can I disply certain data in thingspeak graph rather than display all data with time.
for example If the data start receiving from 10:00 to 11:00 AM , I need to see the data from 10:10AM-10:15AM (how can I make zoom to see only this part and disply it in the graph)?
Regards;
khalid

回答 (2 件)

Kiran Felix Robert
Kiran Felix Robert 2021 年 2 月 3 日
Hi Khalid,
I assume that you are using thingSpeakRead function to read data from a ThingSpeak channel.
You can use following function syntax to obtain the timestamp along with the data. Refer the Documentation of thinkSpeakRead for examples.
[data,timestamps] = thingSpeakRead(__)
You can use logical comparisons on the timestamp data to plot the data from specific time intervals.
The following is an example.
[data,timestamps,channelInfo] = thingSpeakRead(12397,'Fields',[1,4],'NumMinutes',5);
t = datestr(timestamps);
HH = str2num(t(:,13:14)); % Hour
MM = str2num(t(:,16:17)); % Minutes
x = (HH == 10 & MM > 00 & MM <= 15); % Range of data to be plotted
% Plots data between 10:00 AM and 10:15 AM
plot(timestamps(x),data(x))

Niall
Niall 2021 年 5 月 7 日
I've a cheekier solution to this than Kiran has posted. Simply use the datetime function as limits for the plot. I'm using the same assumption that you're using a matlab vizualisation.
[vibration, time] = thingSpeakRead(readChannelID, 'Field', fieldID1, 'NumPoints', 1000, 'ReadKey', readAPIKey);
% t = datetime(Y,M,D,H,MI,S)
tmin = datetime(2021,5,6,13,48,0);
tmax = datetime(2021,5,6,13,57,0);
plot(time, vibration);
xlim([tmin tmax])

カテゴリ

Help Center および File ExchangeVisualize Data についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by