필터 지우기
필터 지우기

ode45 where odefun requires more parameters

조회 수: 105 (최근 30일)
Juliette Salexa
Juliette Salexa 2014년 12월 25일
댓글: Star Strider 2021년 3월 10일

채택된 답변

Star Strider
Star Strider 2014년 12월 25일
I’m not exactly certain what you’re actually asking, since my interpretation of your question is covered in the ode45 documentation. You haven’t listed the code for your ‘odefun’, or described what you want to do, so I’m guessing here.
If I understand correctly, what you want to do is a common way of passing extra parameters to your ODE function.
To use it with ode45, you only pass the ODE solver the ‘t’ and ‘y’ variables:
[t,y] = ode45(@(t,y) odefun(t,y,a,b,c), tspan, ic);
Note that ‘a’, ‘b’, and ‘c’ have to exist in your workspace.
  댓글 수: 3
Rik
Rik 2021년 3월 10일
@(t,y) odefun(t,y,a,b,c)
This creates an anonymous function, with t and y as inputs. The values of the other variables are retrieved when the anonymous function is created:
y=1;
f=@(x) x+y;
y=3;
f(1)
ans = 2
Star Strider
Star Strider 2021년 3월 10일
Rik — Thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (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