Show temperature difference (delta) between 2 temps in a graph

2 views (last 30 days)
Steven Langston
Steven Langston on 26 Nov 2021
Edited: the cyclist on 28 Nov 2021
Hi peeps, new to matlab, i want to show in my channel a graph showing the delta difference between 2 temperatures as a bar graph, so its easy to see where the difference is not optimal for my heat pump, ie between 4 and 5 degrees c.
Can anyone help with some sample code pls?
ta
steve
  2 Comments
Steven Langston
Steven Langston on 27 Nov 2021
Cool, i must learn some code in matlab! Itd be nice to anotate 11pm 4am and other bits. Another language to learn lol
% Enter your MATLAB code below
% Channel ID to read data from
readChannelID = 123456;
% Channel Read API Key
% If your channel is private, then enter the read API
% Key between the '' below:
readAPIKey = '';
% Read Temperature Data. Learn more about the THINGSPEAKREAD function by
% going to the Documentation tab on the right side pane of this page.
temperaturefield1 = thingSpeakRead(readChannelID,'Fields',2,'NumMinutes', 360);
temperaturefield2 = thingSpeakRead(readChannelID,'Fields',5,'NumMinutes', 360);
bar(temperaturefield1-temperaturefield2)

Sign in to comment.

Answers (3)

Steven Langston
Steven Langston on 27 Nov 2021
What id like to do here, is to super impose a average of the these peaks and draw a line across and also show in digits in the space to the top right of the graph the figure of this average.
Something like this - (but i havent added a figure, in the left graph it shold say 4.8C and in the right hand one, about 9.8C)
Any pointers?
Cheers
Steve

the cyclist
the cyclist on 27 Nov 2021
Here is an example similar to what posted in my comment, but added line and text:
rng default
x = rand(1,5);
mean_x = mean(x);
figure
bar(x)
yline(mean_x,'r')
text(0.05,0.95,sprintf('Mean x value is %7.3f',mean_x))
You can read the documentation of all the commands I used, to see more details on how to use MATLAB. This forum is really the best for learning MATLAB from the ground up. I would suggest watching the MATLAB Onramp tutorial, and perhaps take a look at the code in the MATLAB Plot Gallery for ideas on making different types of plot.
  1 Comment
Steven Langston
Steven Langston on 27 Nov 2021
thanks for that, this ideal for watching during my exercise (stepping), 20mins a time!

Sign in to comment.


Steven Langston
Steven Langston on 28 Nov 2021
getting somewhere but cant find much guid on how to ignore values below say 3c and above 6c?
  1 Comment
the cyclist
the cyclist on 28 Nov 2021
% Example temperature input
T = [1 2 3 4 5 6 7 8];
% True/false vector corresponding to elements greater than 3
T > 3
ans = 1×8 logical array
0 0 0 1 1 1 1 1
% True/false vector corresponding to elements greater than 3 and less than 6
(T>3) & (T<6)
ans = 1×8 logical array
0 0 0 1 1 0 0 0
% The elements of T that are >3 and <6
T((T>3) & (T<6))
ans = 1×2
4 5

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!