How to plot an ODE?

8 次查看(过去 30 天)
Carlos Ojeda
Carlos Ojeda 2020-5-3
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]

采纳的回答

darova
darova 2020-5-3
编辑:darova 2020-5-3
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 个评论
darova
darova 2020-5-3
Of course
line(t,y,'color',rand(1,3))
Carlos Ojeda
Carlos Ojeda 2020-5-3
Thank you, kindly, sir!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by