Problem regarding a periodic solution not being saved properly
Show older comments
Hello! I am working on a problem where I have to solve an ODE for time of 10 years and then check when and where that solution becomes periodic. I want to store the value of the periodic solution and the interval when it becomes periodic. This is what I tried so far:
clear all;
p=10;% Number of year for which simulation runs
y0=20000; % Initial condition
tspan=0:1:10*365;
epsilon=1e-10; % Tolerance for periodicty condition which is defined further
t=0:3650; % This t will be used in the following parameter m files
%Calling some parameters
mugen;
Kgen;
d1gen;
delta1gen;
[X Y] = ode15s(@(t,y)para1(t,y,mug,Kg,d1g,delta1g),tspan,y0);
if (X>=365) & (abs(Y(X)-Y(:,X-365))<epsilon) % Check for every
%time value if the solution
%is periodic by using the definition of periodicity.
YcSteady(X)=Y(:,X); % Store the periodic the solution found
XcSteady(X,:)=[X-365 X]; % Store time interval when periodic solution occurs
end
Now, the problem is that it does not store YcSteady which is the time at which periodicity condition is satisfied and XcSteady which is the time interval between which the condition is satisfied!
Thanks!
4 Comments
Star Strider
on 5 Jul 2014
It would be easier to answer if we could run your code. We have no idea what X and Y are numerically, so we cannot evaluate your logic. We at least seem to be missing para1. Attaching it would help.
Rose
on 5 Jul 2014
Rose
on 5 Jul 2014
Rose
on 5 Jul 2014
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations 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!