How to solve a non linear simultaneous equation with 4 unknowns and 4 equations ?

2 views (last 30 days)
How to solve a non linear simultaneous equation with 4 unknowns and 4 equations ?
these are my equations:
% x^2 + y^2 + z^2 = (t^2)*(299792458^2)
% (A + x)^2 + (B + y)^2 + (C + z)^2 = ((q + t)^2 )*(299792458^2)
% (D + x)^2 + (E + y)^2 + (F + z)^2 = ((r + t)^2 )*(299792458^2)
% (G + x)^2 + (H + y)^2 + (I + z)^2 = ((s + t)^2 )*(299792458^2)
where x,y,z, and t are the unknowns and A,B,C,D,E,F,G,H,I,q,r and s are constants.
Any help on how best to go about solving this is appreciated.
-mk

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 16 Mar 2013
Use fsolve
  4 Comments
Manick
Manick on 26 Mar 2013
thanks for the help. I have replaced the unknowns to x(1),x(2), x(3), x(4) but now I have this error instead. Error shown below.
Based on the help file example i used x0 = [-5 -5]. If you could share some info on x0 would be very helpful
could there be something amiss here.
------------ERROR------------
>> x0 = [-5 -5]
x0 =
-5 -5
>> [x,fval] = fsolve(@myfun,x0) Attempted to access x(4); index out of bounds because numel(x)=2.
Error in myfun (line 3) F = [- 89875517873681764*x(4)^2 + x(1)^2 + x(2)^2 + x(3)^2 ;
Error in fsolve (line 241) fuser = feval(funfcn{3},x,varargin{:});
Caused by: Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
Manick
Manick on 26 Mar 2013
I have also tried with x0 = [-5 ;-5 ; -5 ; -5]
it attempts to solve but I get this error at the end:
fsolve stopped because the relative size of the current step is less than the default value of the step size tolerance squared, but the vector of function values is not near zero as measured by the default value of the function tolerance.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!