On 11/9/2012 1:57 PM, Gianluca wrote:
> Hi,
>
> I am new in matlab and I need some help to solve a simple equation. This is my code:
>
> clc
> clear all
>
> C=3.208; % Jacobi constant
> M1= 5.9736e24; % Mass of Earth in kg
> M2= 7.3477e22; % Mass of Moon in kg
> mu=M2/(M1+M2);
>
> for x=4e6:10000:4e6;
> i=1:1:length(x);
>
> syms x y
>
> y(i)=solve(x(i).^2+y(i).^2+2*(1mu)./sqrt((x(i)+mu).^2 + y(i).^2)+2*mu./sqrt((x(i)1+mu).^2+y(i).^2)C, y(i)); % solve the equation
> % for the y variable.
> end
>
> It's a very simple code but Matlab gives me the message:
>
> Warning: Explicit solution could not be found.
>> In solve at 83
>
> It doesn't gime an error; just this message. I don't know where I am wrong. Thanks a lot
>to anyone who will help me.
>
> Regards
>
> Gian
>
I think you are very confused by mixing syms and nonsyms (as is the
case with most users of Matlab).
You say x=4e6:10000:4e6 then you follow that with 'syms x y'
then you later use 'x' again as an array x(i).
Which is it? is 'x' a symbol, or a number or a vector?
Why not stick to one thing and do everything in numerics? Why not
use fsolve?
Nasser
