How to plot ode

2 visualizaciones (últimos 30 días)
Ana Rasic
Ana Rasic el 25 de Nov. de 2020
Editada: Ana Rasic el 26 de Nov. de 2020
I will need a help.So,I have 4 different variables

Respuesta aceptada

Alan Stevens
Alan Stevens el 25 de Nov. de 2020
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 comentarios
Alan Stevens
Alan Stevens el 26 de Nov. de 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 el 26 de Nov. de 2020
Right, I understand:)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by