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

6 次查看(过去 30 天)
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 个评论
the cyclist
the cyclist 2021-11-27
% Make up some data. (Use your real data instead)
rng default
T1 = rand(1,7);
T2 = rand(1,7);
plot(T2-T1)
Now, explain why that doesn't work for you, and I'll explain that you should have given us a lot more detail in your original question. :-)
Steven Langston
Steven Langston 2021-11-27
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)

请先登录,再进行评论。

回答(3 个)

Steven Langston
Steven Langston 2021-11-27
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 2021-11-27
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.

Steven Langston
Steven Langston 2021-11-28
getting somewhere but cant find much guid on how to ignore values below say 3c and above 6c?
  1 个评论
the cyclist
the cyclist 2021-11-28
编辑:the cyclist 2021-11-28
% 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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by