# Matlab ode45

• MATLAB
Hi!!

I have to solve the nonlinear equations of motion in the article (16) (17) (18).

I Trasform the system in a system of first order differential equations but i don't have the initial conditions. Is it possible to solve it with the ode45 matlab function?

#### Attachments

• 2008.pdf
695.2 KB · Views: 286

Ode45 uses among others, the runge kutta routine which is a numerical integration scheme. So no, you cannot solve it in matlab without knowing the initial conditions.

Thanks!

Suppose I have the initial conditions.

I solve the system in this way, tell me if it is write!!

I have a 3 dof system in heave, roll and pitch, of the second order.
I call y=[ heave position, heave velocity, roll position, roll velocity, pitch position, pitch velocity].

I call yd=[heave velocity, heave acceleration, roll velocity, roll acceleration, pitch velocity, pitch acceleration]

I rewrite the system in the form:

function yd=deriv(t,y)

yd(1)=y(2)
yd(2)=f(y,t)
yd(3)=y(4)
yd(4)=f(y,t)
yd(5)=y(6)
yd(6)=f(y,t)

The problem is that in f(y) compare other acceleration terms. Can I write the system in this way?

yd=zeros(6,1)

yd(1)=y(2)
yd(2)=f(t,y,yd)
yd(3)=y(4)
yd(4)=f(t,y,yd)
yd(5)=y(6)
yd(6)=f(t,y,yd)

I think if I know y is it possible. What do you think??

The second question is: to solve the system I only have to write

[t,y]=ode45('deriv',[t0 tf],y0)

Is it true? Or I have to study something related to singularities??

Thanks

AlephZero
Homework Helper
Skipping the mess of notation in the real equations, here's a simple example of what you need to do.

Suppose you have a 2nd order equation like
Ax'' + Bx' + Cx = D

To turn it into two 1st order equations, let y = x'

The equation then becomes
Ay' + By + Cx = D

So now you have two first order equations
x' = y
y' = (D - Cx - By)/A

The intial conditions give the starting values for x and y.

When your Matlab function is called, It is given some values of x and y (and also the time) and your function calculates the values of x' and y'.

Note, the important thing is not get confused about where to use x' and where to use y. They are mathematically identical, but in the numerical method they are two different quantities, and the fact that the numerical values are always equal is just happenstance.

This is the way I have solved the system. Is it correct?

#### Attachments

• function yd.pdf
91.8 KB · Views: 294
Another question.. How can I solve a system like this?

#### Attachments

• function yd1.pdf
93.5 KB · Views: 168
It is an ordinary system..
I know all the constants, the variable are z,theta, phi and tau.

please could anyone tell me if the system can be solved with the ode45 matlab?