interpolation of fortnightly annual temperature data into hourly measurements in matlab

interpolation, matlab, time

Solution

You could first interpolate your data (down to 1 hours) using something like

x = 1:inv(24):365;
T_interp = interp1(t,y1,x,'spline');

Check out Matlab documentation for interp1 (example 2)

and then add a sine onto it. The following a sine of period 1 (24 hours) with amplitude A, with a minimum at 3am.

T_diurn = -A*sin(2*pi*x+(3/24)*2*pi);

Then

T_total = T_diurn + T_interp;

Problem

I have a dataset of annual temperature measurements recorded at fortnightly intervals. The data looks similar to the following: ``` t = 1:14:365; % GENERATE DATA y = 1 + (30-1).*rand(1,length(t)); y1 = 20*sin(2*pi*t/max(t)); % Annual variation °C y1(y1<0) = []; tt = 365/14; time = 1:tt:365; plot(time,y1,'-o'); ``` where it clearly follows a annual temperature cycle. From this I am wondering if it is possible to add a sine function (which would represent a diurnal temperature range) onto the data? For example, from the fortnightly data, if we were to interpolate the series to have 8760 measurements i.e. hourly measurements, for the series to be believable it would need to be characterized by a diurnal temperature cycle in addition to the annual temperature cycle. Furthermore, the diurnal temperature cycle would need to be a function of the temperature measurements at that time i.e. would be greater in the summer than in winter. So maybe it would be better to firstly use linear interpolation to get the data to represents hourly intervals and then add the sine function. Is there a method for writing this into a script? or does anyone have an opinion on how to accurately achieve this?

Original source