What would the code be using ode45?

6 ビュー (過去 30 日間)
Alyssa Cleveland
Alyssa Cleveland 2016 年 5 月 2 日
回答済み: Torsten 2016 年 5 月 2 日
How would I write code using ode45 for time interval [5,25] for uprime = sin(uv) with u(5)=2; vprime=5u-3v with v(5)=5. Will I have to use it twice for each (uprime and vprime) or is there a way I can combine them into one ode45 code?

回答 (1 件)

Torsten
Torsten 2016 年 5 月 2 日
function driver
tspan=[5 25];
u0=2;
v0=5;
y0=[u0 ; v0];
[T,Y]=ode45(@myfun,tspan,y0);
dy=myfun(t,y)
u=y(1);
v=y(2);
dy=zeros(2,1);
dy(1)=sin(u*v);
dy(2)=5*u-3*v;
Best wishes
Torsten.

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by