MATLAB: Problem in using fsolve

fsolvenon-linear

Hi
I am trying to solve the following set of equations but the solver is prematurely stopped and If I alter the MaxIter and MaxEvals then also its showing stopped prematurelly and then I tried to alter the tolerance then its shows no solution found. Can anyone guide how can i obtain the solution for the following set of equations.
function F = compare(X)
rho=1000.0;
F=[
1.0*7.018e-4*4.2850022315+-1.0*1.25e-3*X(2)+-1.0*7.36e-5*X(3)+-1.0*4.47e-5*(4);
-1.0*1.25e-3*X(1)+1.0*1.66e-5*X(4)+1.0*4.47e-5*X(5)+1.0*1.07e-4*X(6);
+1.0*7.36e-5*X(2)-1.0*1.07e-4*X(6)+1.0*1.07e-4*X(7);
1.0*4.47e-5*X(3)+-1.0*4.47e-5*X(5)+-1.0*1.07e-4*X(7);
1.0*0.4*rho*4.2850022315979^2+1.0*807362.4375+-1.0*0.4*rho*X(2)^2 + -1.0*X(9);
1.0*0.4*rho*4.2850022315979^2 + 1.0*807362.4375+-1.0*0.4*rho*X(3)^2+-1.0*X(10);
1.0*0.4*rho*4.2850022315979^2 + 1.0*807362.4375+-1.0*0.4*rho*X(4)^2+-1.0*X(11);
-1.0*0.4*rho*X(1)^2 + -1.0*X(8)+ 1.0*0.4*rho*X(4)^2 + 1.0*X(11);
-1.0*0.4*rho*X(1)^2 + -1.0*X(8) + 1.0*0.4*rho*X(5)^2 + 1.0*X(12);
-1.0*0.4*rho*X(1)^2 + -1*X(8) + 1.0*0.4*rho*X(6)^2 + 1.0*X(13);
-1.0*0.4*rho*X(6)^2 + -1.0*X(13) + 1.0*0.4*rho*X(2)^2 + 1.0*X(9);
-1.0*0.4*rho*X(6)^2 + -1.0*X(13) + 1.0*0.4*rho*X(7)^2 + 1.0*X(14);
1.0*0.4*rho*X(3)^2 + 1.0*X(10) + -1.0*0.4*rho*X(5)^2 + -1.0*X(12);
1.0*0.4*rho*X(3)^2 + 1.0*X(10) + -1.0*0.4*rho*X(7)^2 + -1.0*X(14)
];
end
options = optimset('Display','iter','TolX',1e-7,'MaxFunEvals',18000,'MaxIter',2200);
[Sol,fval,exitflag]=fsolve(@compare,X,options);
following error comes
No solution found.
fsolve stopped because the last step was ineffective. However, the vector of function
values is not near zero, as measured by the default value of the function tolerance.
<stopping criteria details>
where X's are the variables
Please Guide!!!
Regards

Best Answer

You have to write your function so that all of your unknowns are in the same parameter vector.
So calling your parameter vector ‘B’:
B = [V(1) ... V(7) P(1) ... P(7)];
then replace V(1) with B(1), P(1) with B(8), and so forth.
If you intend ‘F’ to be an anonymous function, you have to write it as:
F = @(B,rho) [1.0*10.0*25+-1.0*17.0*B(2)+ ... + -1.0*0.4*rho*B(7)^2 + -1.0*B(14)];
(I abbreviated the function here.) Use the ‘Search’ and ‘Replace’ utilities in the MATLAB Editor to do this more easily.
Your call to fsolve is then:
[x,fval] = fsolve(@(B) F(B,rho),x0)
Your F function will get ‘rho’ from your workspace.
EDIT — Try using different starting values for ‘X’ that are reasonably close to what you expect them to be. Otherwise experiment with them. If it doesn’t converge on a solution after several attempts, it may not have a solution. If you believe it should, go back to your original equations and be sure you wrote ‘F’ correctly.