how to make a function of this system

조회 수: 3 (최근 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 CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by