Numerical solution for a 2nd order ode

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

Community Treasure Hunt

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

Start Hunting!

Translated by