how to make a function of this system

2 ビュー (過去 30 日間)
Jens Petit-jean
Jens Petit-jean 2021 年 5 月 16 日
コメント済み: Jens Petit-jean 2021 年 5 月 16 日
how do I make a function of this ?

回答 (1 件)

Stephan
Stephan 2021 年 5 月 16 日
syms a b y1(t) y2(t)
ode(1,1) = diff(y1,t,2) == a*y2 - cos(diff(y1,t));
ode(2,1) = diff(y2,t) == b*y1 + cos(t)
ode = 
[V,S] = odeToVectorField(ode)
V = 
S = 
odeFun = matlabFunction(V,'vars',{'t','Y','a','b'})
odeFun = function_handle with value:
@(t,Y,a,b)[cos(t)+b.*Y(2);Y(3);-cos(Y(3))+a.*Y(1)]
tspan = [0 1];
yInit = [5 0 1];
a = 1;
b = 2;
[t,y] = ode45(@(t,Y)odeFun(t,Y,a,b), tspan, yInit);
plot(t,y)
  5 件のコメント
Stephan
Stephan 2021 年 5 月 16 日
編集済み: Stephan 2021 年 5 月 16 日
y1 & y2 are the solutions - and due to your system they will only be numerical solutions. They can not be input. So please elaborate what exactly you want to do.
Jens Petit-jean
Jens Petit-jean 2021 年 5 月 16 日
oh yeah sorry I mean dy(1) and dy(2)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by