ThingSpeakPlot being dropped...help | MATLAB IoT Analytics | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
ThingSpeakPlot being dropped...help
No permission to create posts
December 9, 2018
1:31 am
Avatar
kim
New Member
Members
Forum Posts: 4
Member Since:
November 4, 2017
sp_UserOfflineSmall Offline

Hi,
I understand that ThingSpeakPlot is being dropped and in future we should just use plot.

I updated my code accordingly and it all works but now for some reason I cannot get a line just the individual data points.

Even if I use the very simple code below I still do not get a line between the data points.

=====================

[Data, time] = thingSpeakRead(readChannelID, 'Field', FieldID, 'NumPoints', 30, 'ReadKey', readAPIKey);

plot(time, Data,'-o');

========================

I am very new to this so am sure I am missing something simple but any help would be appreciated.

Thanks

Kim

December 10, 2018
10:43 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 861
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

When there are null values between data, you wont get a line.

ed=datetime('yesterday'):hours(5):datetime('now')
myData=[1,NaN,2,NaN,4,3,4]
plot(ed,myData,'-o');

You can remove NaN values from your data with the following:
myData(~isnan(myData))

December 11, 2018
1:43 am
Avatar
kim
New Member
Members
Forum Posts: 4
Member Since:
November 4, 2017
sp_UserOfflineSmall Offline

Thanks for the answer, but I do not see why there would be null values in my data.
The values are read from the channel are always 0, 1, 2, 3 or 4. and they are associated with time values.
I did try to run your code above but it will not plot. It comes back with
"Error using plot
Vectors must be the same length."
I think this is issue with the time function.

December 11, 2018
8:07 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 861
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

When you update different fields separately, ThingSpeak inserts a null value into all the other fields. When you used the function I mentioned, it deleted all the null values in the data, but there were still timestamps for the null points remaining, and thus the arrays didn't match. You can modify the statement I gave you to also delete the timestamps for the null values.

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
25 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

briskpanda, Dejw0089, Yassine Ben Salah, anis, 43994554AKS, suda

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457