How do I plot outside temperature versus time in Matlab?

7 views (last 30 days)
Jessica Poulin
Jessica Poulin on 25 Sep 2019
Commented: KALYAN ACHARJYA on 25 Sep 2019
Hello,
I'm not sure how to graph the following code in Matlab (Temperaure over 24 hour period should look sinusodal):
for t = 1:24
T(t,1) = (((Tmax - Tmin)/2)+((Tmax - Tmin)/2) * sin(((t - 9)/12)*Pi));
Thank you!
  6 Comments
KALYAN ACHARJYA
KALYAN ACHARJYA on 25 Sep 2019
Where is temperature data to plot across time hours?

Sign in to comment.

Answers (2)

Kevin Phung
Kevin Phung on 25 Sep 2019
Edited: Kevin Phung on 25 Sep 2019
no for loop needed.
Tmax = 310;
Tmin = 298;
t=(1:24)'; % transposed if you want a column vs row
T = ((Tmax - Tmin)/2) + ((Tmax-Tmin)/2)*sin((t-9)/12*pi)
figure
plot(T)

rough93
rough93 on 25 Sep 2019
Edited: rough93 on 25 Sep 2019
clc; clear
Tmax = 310; % Maximum daily temperature (3pm)
Tmin = 298; % Minimum daily temperature (3am)
x = 1:24;
Graph = 12*sin(((x+3)*pi)/12);
plot(Graph)
This assumes you start at mid day.

Community Treasure Hunt

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

Start Hunting!