Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

2nd order ODE with variable coefficients

Asked by Sushant on 9 Nov 2013
Latest activity Commented on by Sushant on 14 Nov 2013

Ok so I am new to matlab and need help to solve this ODE. Plz tell me how to do it in matlab.

y'' + y'(0.75 + 0.5sin(x)) + y(1.3225 + 0.5cos(x) + 0.1875sin(2x)) = 0

Initial Conditions: y(0) = 0.6 and y'(0) = 0

Thankyou

0 Comments

Sushant

Products

No products are associated with this question.

1 Answer

Answer by Ben Petschel on 12 Nov 2013
Accepted answer

You'll need to rewrite the second-order ODE as a first-order vector ODE. Put y1=y, y2=y1', so y2'=y''. Try ode45, with

f = @(x,y)[y(2);-(y(2)*(0.75+0.5*sin(x))-y(1)*(1.3225+0.5*cos(x)+0.1875*sin(2*x))];
[x,y] = ode45(f,[0,xmax],[0.6;0]) 

1 Comment

Sushant on 14 Nov 2013

Oh I see. That was a really nice way to do it :) Thanks a lot :)

Ben Petschel

Contact us