what chace i need to make better answer? check fsolve
Show older comments
I have this algorithm:
function F=giaiphuongtrinh(x)
Pv=5;
Pred=6;
Pl=10;
Ebmax=20;
Ebmin=2;
Eb=2;
Pdiesel=2;
Edum=0;
if (Pv+Pred)>=Pl
x(2)=Pv+Pred-Pl
Ech=x(2)
if Ech<=(Ebmax-Eb)
Eb=Eb+Ech
x(3)=0
else
Eb=Ebmax
x(3)=Ech-(Ebmax-Eb)
end
else
x(1)=Pl-(Pv+Pred)
Edch=x(1)
if Edch<=(Eb-Ebmin)
Eb=Eb-Edch
else
Eb=Ebmin
end
end
F=(Pl-(Pv+Pred+Pdiesel+x(1)-x(2)-x(3)))
I ran:
x0=[0;0;0];
options = optimoptions('fsolve','Display','iter');
[x,fval] = fsolve(@giaiphuongtrinh,x0,options)
and the result is:
4 20 3.81809e-28 1.95e-14 1e-06 1.97781e-09
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
x =
-2.0000
0
0
fval =
-1.9540e-14
I think it must be another result. Do you see something wrong? Please help me. Thank you so much.
Accepted Answer
More Answers (1)
Steven Lord
on 13 Oct 2016
0 votes
Why do you believe something is wrong?
The message that was displayed is NOT, repeat NOT an error. If it had been an error the message would have appeared in red text and probably would have contained the word "error". That is a informational status message telling you why fsolve stopped iterating.
1 Comment
Quynh tran
on 13 Oct 2016
Categories
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!