"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i60jak$6ib$1@fred.mathworks.com>...
> "Mamon " <mamoon_hatmal@yahoo.com> wrote in message <i602m1$3v$1@fred.mathworks.com>...
> > Hi ALL ;
> > I'm a PhD student at USC, I'm trying to use matlab to solve a group of equations ( I want to find the values of x(1),x(2),x(3),x(4),x(5),and x(6)), I'm trying to use fsolve in *.m file because I need the results to be written directly for output file, could you please help me in that, the code that I use is between the two lines (but it always gives me an error):
> > 
> > function F = myfun(x)
> > x=zeros(3,2);
> > F(1)=inline('(x(1)^2)+74.201(17.228*x(1))+(x(2)^2)+5.341(4.622*x(2))+(x(3)^2)+165.431(25.724*x(3))1398.760','x');
> > F(2)=inline('(x(4)^2)+74.201(17.228*x(4))+(x(5)^2)+5.341(4.622*x(5))+(x(6)^2)+165.431(25.724*x(6))750.760','x');
> > F(3)=inline('(x(1)^2)+32.217(11.352*x(1))+(x(2)^2)+49.323(14.046*x(2))+(x(3)^2)+341.289(36.948*x(3))858.490','x');
> > F(4)=inline('(x(4)^2)+32.217(11.352*x(4))+(x(5)^2)+49.323(14.046*x(5))+(x(6)^2)+341.289(36.948*x(6))327.610','x');
> > F(5)=inline('(x(1)^2)+13.542(7.360*x(1))+(x(2)^2)+68.013(16.494*x(2))+(x(3)^2)+45.239(13.452*x(3))1608.010','x');
> > F(6)=inline('(x(4)^2)+13.542(7.360*x(4))+(x(5)^2)+68.013(16.494*x(5))+(x(6)^2)+45.239(13.452*x(6))912.040','x');
> > F(7)=inline('x(1)^2(2*x(1)*x(4))+x(4)^2+x(2)^2(2*x(2)*x(5))+x(5)^2+x(3)^2(2*x(3)*x(6))+x(6)^2224.101','x');
> > x0 = [1; 1; 1; 1; 1; 1];
> > options=optimset('Display','iter');
> > x=fsolve(F,x0,options);
> > end
> > 
> >
> > also I have a question about how can we get all the solutions for the above equations, because fsolve now gives just one solution, and I wonder if there is a method to produce all the solutions or if we can change the initial guess by using " for loop".
> >
> > any help is appreciated,
> > Thank you,
> > Ma'mon hatmal
>          
> You are trying to solve seven different equations with only six unknowns. In general there would be no solution. Equations F(1), F(3), and F(5) represent the intersection between three spheres in x(1), x(2), and x(3) space and would have either two solutions, one solution, or none. Equations F(2), F(4), and F(6) give three spheres in x(4), x(5), and x(6) space with the same centers as in the other three spheres but with apparently different radii. The last equation F(7) is the assertion that the two solutions in the first set are a given distance from those in the second set. As you can see, this last would not be true in general. You should not be trying to solve all seven but only the three F(1), F(3), and F(5) together and then F(2), F(4), and F(6) together as a separate problem. Then you can use F(7) to check whether any combination from the other solutions satisfy it.
>
> If you are having trouble finding all solutions, you should know that there is a fairly direct way of solving the problem of the intersection of three spheres. It involves first finding where the line connecting the two solutions passes through the plane of the three centers, and next moving out along this line an appropriate distance.
>
> Roger Stafford
Hi Roger,
finding all the solutions is one of the problems, my main problem now is to use fsolve inside *.m file, I did that (as indicated in the above code) but I always receive an error, so I wonder if you have any idea how to correct the code to make fsolve work in *.m file.
thank you,
Ma'mon
