"samira" wrote in message <iufp95$jac$1@newscl01ah.mathworks.com>...
> Hi
>
> I would like to use solve for solving nonlinear equations like this:
>
> one=sym('(x1)^2(y1)^2=0.5^2')
> two=sym('(x1.5)^2(y1)^2=0.5^2')
> [x,y]=solve(one,two)
>
> I want to make a function for that, so by giving different constants I can get different results.
> Can you help me to see how can I store constants in above code in a matrix (like [1 1 0.5; 1.5 1 0.5;]) and use matrix arrays in defining my equations?
>
> Thanks
         
When I used 'solve' on your problem, the answer it gave was much too long and complicated for my tastes, so I worked out a simpler procedure for you.
To solve the equations
(xa)^2  (yb)^2 = c^2
(xd)^2  (ye)^2 = f^2
for arbitrary constants a, b, c, d, e, and f, do this:
ad = ad; be = be; adbe = ad^2be^2;
h = sqrt((adbec^2f^2)^24*c^2*f^2);
xf = (a+d)/2ad*(c^2f^2)/(2*adbe); xr = be*h/(2*adbe);
yf = (b+e)/2be*(c^2f^2)/(2*adbe); yr = ad*h/(2*adbe);
x1 = xf+xr; y1 = yf+yr;
x2 = xfxr; y2 = yfyr;
Then the pair (x1,y1) will be one solution and (x2,y2) another. Note that some of the solutions will be complexvalued.
Roger Stafford
