MATLAB: How to smooth seasonal averages into a continuous function

differential equations

Hi, I have a system of four non linear ordinary differential equations:
dy(1,1) = (k1(t).*(y(4)-y(1)).*y(3))./(y(2)+y(3)-1e-12) - k2(t).*y(1).*(y(2)./(y(2)+y(3)-1e-12)) ;
dy(2,1) = (mu(t).*(y(2).^2)/(K(t).^2+y(2).^2)).*exp((-y(1)).*k(t))-(k3(t).*y(1).*y(2))./(y(2)+y(3)-1e-12)-(d1(t)+gamma1(t).*y(4)).*y(2);
dy(3,1) = (k3(t).*y(1).*y(2))./(y(2)+y(3)-1e-12)-(d2(t)+gamma2(t).*y(4)).*y(3);
dy(4,1) = r(t).*y(4).*(1-(y(4)./(alpha(t).*(y(2)+y(3)-1e-12))));
% Nested k1
function y = k1(t)
y = [0.1593,0.1460,0.1489,0.04226];
idx = logical(histc(t,[0,91.25,182.5,273.75,365]));
y = y(idx);
end
% Nested k2
function y = k2(t)
y = [0.04959,0.03721,0.04750,0.008460];
idx = logical(histc(t,[0,91.25,182.5,273.75,365]));
y = y(idx);
end
There are 12 parameters(like k1,k2 and so on) involved in the model and they are known as their seasonal averages in the literature. I want to construct continuous functions from the seasonal averages by using interpolation/approximation. I have no idea where to start from! Your guidance, comments, reference to any book or code will be greatly appreciated. Thanks

Best Answer

Use conv() to get a sliding average
seasonalAverage = conv(dailyData, ones(1,90)/90);
You should pad your signal on both sides with copies of the year's data so that you get continuous wrap around averaging and not get any "edge effects" when the 90 day window overlaps the edge. For example if the window goes from Dec. 1 to Feb. 28, you want to make sure you have some data there in December.
Make sense?