How to plot an ODE?

조회 수: 4 (최근 30일)
Carlos Ojeda
Carlos Ojeda 2020년 5월 3일
댓글: 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