Réponse acceptée

Alan Stevens
Alan Stevens le 25 Nov 2020

0 votes

First, you should combine your three "prom" ode functions into one
IC = [n0 m0 h0];
[t, NMH] = ode45(@(t,nmh) prom(t,nmh,V1), tspan, IC);
n = NMH(:,1):
m = NMH(:,2);
h = NMH(:,3);
...
where your ode function is something like
function dNMHdt = prom(t,NMH,V1)
n = NMH(1);
m = NMH(2);
h = NMH(3);
dndt = ....;
dmdt = ....;
dhdt = ....;
dNMHdt [ dndt; dmdt; dhdt];
end
Then you can think of doing something along the lines of:
V1 = [20 40 60 80];
for i = 1:4
[t, NMH] = ode45(@(t,nmh) prom(t,nmh,V1(i)), tspan, IC);
n(:,i) = NMH(:,1);
m(:,i) = ....etc.
end

4 commentaires

Ana Rasic
Ana Rasic le 25 Nov 2020
Thank you so much.I will try :)
Ana Rasic
Ana Rasic le 26 Nov 2020
Hey,I just wanna say that everything work with little modifications, so thank you again
I have just one more question
What exactly mean this line, n(:,i) = NMH(:,1), what's happen when I put this in the loop?
Alan Stevens
Alan Stevens le 26 Nov 2020
It saves the values of NMH for that value of i (if I've got the syntax right!) so that you can plot/display/examine all four sets of values after the loop is completed. Similarly for m and h.
Ana Rasic
Ana Rasic le 26 Nov 2020
Right, I understand:)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming 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!

Translated by