How do I create a bar chart?
3 ビュー (過去 30 日間)
古いコメントを表示
Stigh Aarstein
2020 年 10 月 12 日
コメント済み: Christopher Stapels
2020 年 12 月 22 日
Hi,
I'm quite new to the field of manipulating my data and can't find any examples of my goal.
I have a channel with a field (fieldMotion) where I receive data from a motionsensor where I simply write ThingSpeak.setField(3, 1) for every motion detected. I would like to create a bar chart (in a Visualization) where I sum every 1's within an hour to show amount of motions per hour for a day. Also I would like to do the same per day for a week. Could anybody please help me with a working code I could use to make this work?
0 件のコメント
採用された回答
Christopher Stapels
2020 年 10 月 13 日
channelID=12397;
data = thingSpeakRead(channelID,'Fields',[1,4],'NumPoints',3,'OutputFormat','TimeTable');
% might have to add api key for private channels
sumData=retime(data,'hourly','sum'); % I think daily is also possible for your second request.
plot your bar chart
bar(sumData.Timestamps,sumData.TemperatureF);
You will probably have to change TemperatureF to the name of your field. Leave the semicolon off the first command to see the varaible names when you run it.
Then add it to the channel where you want to see it.
その他の回答 (0 件)
コミュニティ
その他の回答 ThingSpeak コミュニティ
参考
カテゴリ
Help Center および File Exchange で Read Data from Channel についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!