Numerical solution for a 2nd order ode

9 ビュー (過去 30 日間)
Abby Perroit
Abby Perroit 2017 年 3 月 30 日
コメント済み: Jan 2017 年 3 月 31 日
Hi everyone, I'm struggling to find the numerical solution for the following equation and conditions:
y'' + (0.2)*y' - y - y^3 = (0.3)*cos(wt) y(0) = 0 y'(0) = 0
I need to plot a numerical solution from ti = 0 to tf = 100 for w = 0.8:0.1:1.5. I am really new to matlab so fair warning, here's what I've got so far:
syms y t;
a = y;
b = Dy;
Db = (0.3)*cos(w*t)-(0.2)*b + a - a^3;
figure;
hold on
for x = 0.8:0.1:1.5
ezplot(subs(Db, 'w', x), [0 100])
end
hold off
axis ([0 100 0 3])
title 'Numerical solutions of D2y + (0.2).*Dy - y - y.^3 = (0.3).*cos(w.*t) when w = 0.8, 0.9,..., 1.4, 1.5'
legend('w = 0.8', 'w = 0.9', 'w = 1.0', 'w = 1.1', 'w = 1.2', 'w = 1.3', 'w = 1.4', 'w = 1.5')
I'd appreciate any guidance or feedback, thank you!
  1 件のコメント
Jan
Jan 2017 年 3 月 31 日
"Numerical" solution means, that you do not use "syms".
Start with converting the 2nd order equation to a system of equations of the 1st order.

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

回答 (1 件)

Torsten
Torsten 2017 年 3 月 31 日
編集済み: Torsten 2017 年 3 月 31 日
Rewrite your ODE as
y1'=y2
y2'=-0.2*y2+y1+y1^3+0.3*cos(w*t)
and use ODE45 to solve.
Look at the examples provided under
https://de.mathworks.com/help/matlab/ref/ode45.html
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