How to plot an ODE?

5 visualizzazioni (ultimi 30 giorni)
Carlos Ojeda
Carlos Ojeda il 3 Mag 2020
Commentato: Carlos Ojeda il 3 Mag 2020
Silly question but how can I plot a simple ODE like the following?
My ODE is:
dy/dt=1-(t/n)-y
where n is an array
n=[1 2 3 5 Inf]

Risposta accettata

darova
darova il 3 Mag 2020
Modificato: darova il 3 Mag 2020
Use for loop to solve equation 5 times for each n
n = [1 2 3 5 inf];
f = @(t,y,n) 1-t/n+y;
for i = 1:length(n)
[t,y] = ode45(f,[0 5],ic,[],n(i));
line(t,y)
end
  6 Commenti
darova
darova il 3 Mag 2020
Of course
line(t,y,'color',rand(1,3))
Carlos Ojeda
Carlos Ojeda il 3 Mag 2020
Thank you, kindly, sir!

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by