0
votes

UPDATE I am trying to find the Lyapunov Exponents given in link LE. I am trying to figure it out and understand it by taking the following eqs for my case. These are a set of ordinary differential equations (these are just for testing how to work with cos and sin as ODE)

f(1)=ALPHA*(y-x);
f(2)=x*(R-z)-y;
f(3) = 10*cos(x);

and x=X(1); y=X(2); cos(y)=X(3);

f1 means dx/dt;f2 dy/dt and f3 in this case would be -10sinx. However,when expressing as x=X(1);y=X(2);i am unsure how to express for cos.This is just a trial example i was doing so as to know how to work with equations where we have a cos,sin etc terms as a function of another variable.

When using ode45 to solve these Eqs

[T,Res]=sol(3,@test_eq,@ode45,0,0.01,20,[7 2 100 ],10);

it throws the following error

??? Attempted to access (2); index must be a positive integer or logical.

Error in ==> Eq at 19
x=X(1); y=X(2); cos(x)=X(3); 
  1. Is my representation x=X(1); y=X(2); cos(y)=X(3); alright?
  2. How to resolve the error? Thank you
1

1 Answers

1
votes

No your representation is completely wrong. You can't possibly set values in this way! For a start, you are trying to assign a value X(3) to a function.

first I am not sure you understand the difference between

x=4

and

4=x

which are completely different meanings. If you understand this, you'll see that you can't possibly assign using cos(x)=X(3).

Second: what is the function sol() you are calling? have you defined it?

Third, to solve or evaluate ODEs you should be using deval or solve functions in matlab. Their help files should give you examples.