How to solve this equation with ode45?

1 回表示 (過去 30 日間)
Califfo
Califfo 2019 年 12 月 23 日
コメント済み: 渴健 王 2021 年 11 月 24 日
I would like to solve this equation with ode45 suite:
in which:
  • ;
Is it correct to rewrite this equation as a system of first-order ODEs by making the following substitutions?
I will be grateful for any help!

回答 (1 件)

krishna teja
krishna teja 2019 年 12 月 23 日
yes, you are right, you should split equations
function dydt = ode45fcn(t,y)
p = 2.67;
a = 0.25;
ag = 0.5*sin(4*pi*t); % your model requrires extra input 't'
g = 9.8;
dydt = zeros(2,1);
dydt(1) = y(2);
dydt(2) = -p*( sin(a*sign(y(1)) - y(1)) + ag/g*(cos(a*sign(y(1))-y(1))) );
tspan = 0:0.000001:1;
y0 = [0 0.01];
[t,y] = ode45(@(t,y) ode45fcn(t,y), tspan, y0);
subplot 121
plot(t,y(:,1))
title('dot_y')
subplot 122
plot(t,y(:,2),'-r')
title('ddot_y')
  1 件のコメント
渴健 王
渴健 王 2021 年 11 月 24 日
good idea

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

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by