フィルターのクリア

Solution of spring mass equation with cubic stiffness

1 回表示 (過去 30 日間)
Murat Yetkin
Murat Yetkin 2018 年 10 月 10 日
再開済み: Walter Roberson 2018 年 12 月 22 日
I have below equation to solve with a given time series of f(t). Is there any idea how to do it in Matlab with ode solvers?
m=1; c=1; k=10; k2=20; k3=20;
my''+cy'+ky+k2*y^2+k3*y^3=f(t)

回答 (1 件)

Torsten
Torsten 2018 年 10 月 10 日
function main
tf = ...; % times for f-vector
f = ...; % f vector
tspan=[0 10000];
y0=[0;1];
[t,y]=ode45(@(t,y) myode1(t,y,tf,f),tspan,y0);
end
function dy = myode1(t,y,tf,f)
m=1; c=1; k=10; k2=20; k3=20;
f_actual=interp1(tf,f,t);
dy=zeros(2,1);
dy(1)=y(2);
dy(2)=(f_actual-c*y(2)-k*y(1)-k2*y(1)^2-k3*y(1)^3)/m;
end
  2 件のコメント
Murat Yetkin
Murat Yetkin 2018 年 10 月 11 日
編集済み: Murat Yetkin 2018 年 10 月 11 日
thank you for reply, but this produced results as 'NaN'. also, how did you decide the initial conditions as [0;1]?
Torsten
Torsten 2018 年 10 月 11 日
編集済み: Torsten 2018 年 10 月 11 日
thank you for reply, but this produced results as 'NaN'.
Did you include your tf and f vectors for the tspan period?
also, how did you decide the initial conditions as [0;1]?
I decided it because you didn't supply any.
Best wishes
Torsten.

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

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by