October 18, 2015
I have a few devices sending 3 variables to thingspeak every 30 minutes... device id, temperature, and mode.
I need some help making one graph to display the following:
1) a separate line plotted on the same graph for each deviceID
2) for each line plotted, I would like the line style to change from a solid linestyle when mode is 1 to a dashed linestyle when mode is 0?
3) y axis should represent temperature and x axis should represent the timestamp
I'm new to thingspeak and matlab...the best I have been able to achieve so far is one line on a graph but it has all temperatures and mode from all devices...I haven't been able to separate the lines by deviceID and have no clue if matlab can plot a line using different linestyles *partway* through the line.
Any gurus out there that can point me in the right direction?
January 19, 2011
It is possible to plot multiple lines on a single graph in MATLAB using the 'plot' function:
According to the documentation, you would provide your data to the function as a column vector, or matrix, depending on the number of lines to plot.
Lines can be assigned a line style or LineSpec. At this time, it does not appear possible for segments between points to be different LineSpecs. However, it is possible to break the data down into more line segments and assign LineSpecs to each line segment. See the following example in the documentation:
August 22, 2015
Plotting is a huge subject in MATLAB: See the doc for the plot command here:
There are lots of ways to do this, but here's something to get you started:
% Generate some data
d = table;
d.timestamp = (datetime('now') - minutes(240):minutes(30):datetime('now'))';
d.temperature = [23;45;56;24;44;56;23;43;55];
d.id = [1;2;3;1;2;3;1;2;3];
d.mode = [1;1;1;1;1;1;0;0;0];
% Plot by sensor ID
plot(d.timestamp(d.id == 1),d.temperature(d.id == 1),...
d.timestamp(d.id == 2),d.temperature(d.id == 2),...
d.timestamp(d.id == 3),d.temperature(d.id == 3))
However, it doesn't solve your "dotted when mode is 1" request. You can do this, but it'll take some more work. You'll need to plot the non dotted and dotted separately. So, you'll have 6 lines in your plot.
Most Users Ever Online: 114
Currently Online: samdavies
Currently Browsing this Page:
Guest Posters: 1
Newest Members:Lakshmanaprakash S B, bettetj60, ronnievw3, bessiesj18, Pavan kumar, Williampup
Administrators: Hans: 387, lee: 457