How do I plot outside temperature versus time in Matlab?

5 次查看(过去 30 天)
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 个评论
rough93
rough93 2019-9-25
Gotcha! See my answer below. If you want to start from midnight instead of mid day, change the +3 to -9.

请先登录,再进行评论。

回答(2 个)

Kevin Phung
Kevin Phung 2019-9-25
编辑:Kevin Phung 2019-9-25
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 2019-9-25
编辑:rough93 2019-9-25
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.

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by