Hello,

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?

Thanks,

Marco

moballa,

It is possible to plot multiple lines on a single graph in MATLAB using the 'plot' function:

http://www.mathworks.com/help/matlab/ref/plot.html

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:

http://www.mathworks.com/help/matlab/ref/plot.html?searchHighlight=plot#btzpndl-1

Hi,

Plotting is a huge subject in MATLAB: See the doc for the plot command here:

http://www.mathworks.com/help/matlab/ref/plot.html

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];

d

% 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.

-Rob

Senior Development Manager for IoT and Hardware Interfacing for MATLAB at MathWorks. Visit ThingSpeak.com to explore the IoT Analytic platform that speaks MATLAB made for engineers and scientists. You can collect, analyze, and act in 5 minutes or less!

Most Users Ever Online: 114

Currently Online: jacktheripper125, pudderz

21 Guest(s)

Currently Browsing this Page:

1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

bbruno22

pudderz

Utkya

Poornak26

LindasHed

reddysiva

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee