3d visualization but with only 6 trailing days | 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
3d visualization but with only 6 trailing days
No permission to create posts
November 21, 2018
11:42 am
Avatar
13enji1000
New Member
Members
Forum Posts: 2
Member Since:
November 20, 2018
sp_UserOfflineSmall Offline

Hi

I am new to this platform and Matlab but I have manage to get to the point where I can make a 3d bar chart of temperatures for the trailing 6 days. You can view the result at the bottom of this page:

https://thingspeak.com/channels/630872

My code is below. Can anyone help me understand why, no matter how much data I bring back (I've checked that I am getting more than 6 days worth of data), I only get a trailing 6 days of data. You can see from the code below, the 'trailingdays' variable is set to 10 but I still only get 6 days of data. Can someone help me understand why? Also any suggestions on ways / functions I could have used to make the below more simple, would be very much welcomed.

Thanks

Ben

readChannelID = 624093;

readAPIKey = 'WEA8ALITMF5CLN4N';

trailingdays = 10

[data,timestamps] = thingSpeakRead(readChannelID,'ReadKey',readAPIKey,'Fields',[1],'NumDays',trailingdays);

TT1 = array2timetable(data,'RowTimes',timestamps);
TT2 = retime(TT1,'hourly','mean');

mytime=(TT2.Time);
mydata=(TT2.data);

mytimeTZ = datetime(mytime, 'TimeZone','UTC');
mytimeTZ.TimeZone = 'America/New_York';

myhour=hour(mytimeTZ)
myday=day(mytimeTZ)

h=zeros(24,trailingdays);

t=datetime
tTZ = datetime(t, 'TimeZone','UTC');
tTZ.TimeZone = 'America/New_York';

tominus=(day(tTZ)-trailingdays-1)

for i = 1:(length(myhour))
x = int8((myhour(i))+1)
y = int8((myday(i))-tominus);
z = mydata(i);
h(x,y) = z;
end

for i = 1:trailingdays+1
[DayNumber, DayName] = weekday(t-trailingdays-1+i)
xnames{i}=DayName
end

bar3(h)
az =27.5;
el = 20;
view(az, el);
ylim([0 25])
ynames = {'00:00'; '06:00'; '12:00'; '18:00'; '24:00'};
set(gca,'ytick',[0 6 12 18 24],'yticklabel',ynames)
set(gca,'xtick',[1:trailingdays+1],'xticklabel',xnames)
xtickangle(90)

title(['Outdoor Temp - ',num2str(trailingdays),' days trailing'])
xlabel('Day')
ylabel('Time of Day')
zlabel('Temperature')

November 24, 2018
11:57 pm
Avatar
cstapels
Moderator
Members


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

How often does your channel update? ThingSpeak has an 8000 point limit per query. If your channel updated every minute, you would only be able to get 6 days in one read.
You may be able to increase the time span using averaging of median. You can also perform multiple reads and concatenate the data. Be careful when performing too many successive reads however.

One good workaround is to create a second channel that aggregates the data from the first channel.
Please let us know if that helps.

November 25, 2018
6:36 pm
Avatar
13enji1000
New Member
Members
Forum Posts: 2
Member Since:
November 20, 2018
sp_UserOfflineSmall Offline

Hey cstapels

Thank you so much for that information. I do indeed update the channel every minute, so that sounds like the problem. I will probably try making 2 reads of data but I was more concerned that I couldn't work out the problem with my code. Very helpful.

Thanks again.

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
20 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:

qkpham, SANGAMNATH B, swatiiot, kalyanigaware16@gmail.com, Romi, Drakan01

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457