(x" + sin(x) = 0). Use MATLAB’s ode45 solver to generate a numerical solution of this system over the.i nee the function w = f(t,x), x =z(1) and the code for w in order to solve the IVP

Answers (1)

Some hints:
Turn this single 2nd order equation into two 1st order equations. E.g., define a 2-element vector y (or some other arbitrary name of your choosing) with the following relationships (in all cases the ' means derivative, not transpose):
y = a 2-element vector
y(1) = x <-- I.e., the x from your original ODE x'' + sin(x) = 0
y(2) = y(1)' = x'
This leads to the following relationship:
y(2)' = (y(1)')' = (x')' = x''
So the system of derivative equations in terms of y(1) and y(2) is then
y(1)' = y(2)
y(2)' = some expression involving y(1) and y(2) <-- In your case only y(1)
For the y(2)' part, your task is to solve the x'' + sin(x) = 0 for x'' and then use that to determine the equation for y(2)' in terms of y(1).
Once you have done that you can code up the two lines for the derivative of y, one line for y(1) derivative and one line for y(2) derivative. Then create a function from these two lines that you can use for the input to ode45. You can look at Example 2 at this link to see a similar problem using a 2-element vector y:

Tags

Asked:

on 15 Nov 2015

Edited:

on 15 Nov 2015

Community Treasure Hunt

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

Start Hunting!