I can't seem to plot this function with the given information. I'm not sure that my function is correct.

T = Tmean + (Tpeak - Tmean)cos(w(t - tpeak))

Tmean is the mean temp. over a year
Tpeak is the highest daily mean temp.
tpeak is the day that the peak temp. occurs
w has the value 2π/365

Write a function that takes Tpeak, tpeak and Tmean as inputs and outputs
the following return values:
1) The temp. for every day of the year as a 365-element vector
2) The minimum temp. for the year
3) The day with the minimum temp.

My function for this is:

function  [ev_day, yr_min, day_min]= av_temp(hd, myr, td)

% the inputs
% hd: highest daily mean temp
% td: the day that peak temp occur
% myr: mean temp over a year

%the outputs
% ev_day: temperature for everyday
% yr_min: minimum temperature for the year
% day_min: minimum temperature

t = 1:365
[ev_day, yr_min, day_min] = myr + (hd - myr)*cos(2*pi/365*(t - td));
[ev_day, yr_min, day_min] = min(myr,td)

Given that:
Tmean = 19.8
Tpeak = 25.9
tpeak = 13
How do I plot temp. for every day of the year?

Recommended Answers

All 2 Replies

What language are you trying to do this in? (looks like Matlab to me)

Oh forgot to mention it is MATLAB

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.