How to smooth seasonal averages into a continuous function?

2 views (last 30 days)
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
  2 Comments
Jan
Jan on 25 Mar 2013
The question is not clear. Actually the posted code does not concern theproblem at all, when I understand correctly, but you only want a continuos function to approximate your k1(t) to k12(t). So please post the available values of these parameters and explain, which function should be used for fitting.
Rose
Rose on 13 Apr 2013
Hello @Jan Simon, Sorry for the inconvenience. Let me explain the parameter values. Consider parameter k1(t) first: from 0 to 91.25, the average value of k1(t) is 0.1593, from 91.25 to 182.5, the average value of k1(t) is 0.1460. From 182.5 to 273.75, the value of k1(t) is 0.1489 and from 273.75 to 365 its value is 0.04226. Therefore it is a piece wise constant function. But my problem is to interpolate it as a continuous function. I tried the built in Matlab function pchip but the problem is that i used the value of the parameter to be equal to the average value at the mid of every interval, which is wrong. So, I don't know what to do. I could not find any example in the literature where they smoothen the piecewise constant functions. Any help will be greatly appreciated.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 13 Apr 2013
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?
  2 Comments
Rose
Rose on 13 Apr 2013
Edited: Rose on 13 Apr 2013
Sounds like this is what i have been looking for. But i don't have daily data. For each parameter, I just have 4 average values (one for each season)(. Would it be possible for to refer me some example (any webpage, book or research paper?) Thanks a ton for your answer though!
Image Analyst
Image Analyst on 14 Apr 2013
There are tons of web sites discussing convolution - it's the basis for linear filtering. If you just want to replicate constants then use repmat(), for example to get a year's worth:
seasonalMeans = ones(1,365);
seasonalMeans(1:91) = seasonalMeans(1:91) * winterMean;
seasonalMeans(92:182) = seasonalMeans(92:182) * springMean;
and so on.

Sign in to comment.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!