ODE45 help varying values
Afficher commentaires plus anciens
So I have a function and I am trying to solve it via ODE45. It works perfectly and gives me my solution and plots it on a nice little graph. What I am struggling to understand is that when I change my parameter value, a different amount of Y values are produced. For example, my code is as follows;
z=0;
f = [1 2 3]
ft =[1 2 3];
g = [4 5 6];
gt = [1 2 3];
Time = [0 30];
IC = 2.5;
for a = [1:3]
for b = [1:3]
Q = [a b];
[t,y] = ode45(@(t,y) Test(t,y,Q,ft,f,gt,g), Time, IC);
end
y=y'
z=z+1;
out(z,:) = [a b y]
end
with an ODE file;
function dydt = Test(t,y,Q,ft,f,gt,g)
f = interp1(ft, f, t,'linear', 'extrap');
g = interp1(gt, g, t, 'linear', 'extrap');
dydt = Q(1)*f+Q(2)*g*y;
end
Now if for example I let a=1 and b=1, then I get 1845 Y values. If however I set a=1 and b=2 then I get 2427 Y values. I really do not understand how simply changing the parameter gives a different 'amount' of solutions. It is making it very difficult to store my solutions in a matrix since I keep getting an error about them not matching up.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!