필터 지우기
필터 지우기

How do i solve a second order ODE with variable coefficients?

조회 수: 3 (최근 30일)
Enterprixe
Enterprixe 2017년 2월 25일
답변: Star Strider 2017년 2월 25일
I am fairly new to MATLAB and i don't really know how to solve this equation. y''+(exp(-10t)+sen(10t))y'+y=0 If anyone could help me it would me much appreciated

채택된 답변

Star Strider
Star Strider 2017년 2월 25일
This seems to work:
% % % y''+(exp(-10t)+sen(10t))y'+y = 0
syms t y(t) Y
D1y = diff(y,t);
D2y = diff(y,t,2);
Eqn = D2y + exp(-10*t) + sin(10*t)*D1y + y == 0;
yode = odeToVectorField(Eqn);
Yodefcn = matlabFunction(yode, 'Vars',[t Y]);
% Yodefcn = @(t,Y) [Y(2);-exp(t.*-1.0e1)-sin(t.*1.0e1).*Y(2)-Y(1)];
tspan = [0 15];
Y0 = [0 0];
[T,Y] = ode45(Yodefcn, tspan, Y0);
figure(1)
plot(T, Y)
grid
If you do not have the Symbolic Math Toolbox, delete that part of my code and use the commented ‘Yodefcn’ instead, with the rest of my code.

추가 답변 (0개)

카테고리

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