How to use options in fsolve
3 views (last 30 days)
Show older comments
Hello,
I'm trying to use the options in fsolve but i didn't understand how i can do...
I know that i have to do fsolve(@(x) myfunz,x0,options) but I don't know what i have to write, option=..?
This is my code:
j=0;
xsol=zeros(13,28);
T21=zeros(1,28);
for t=0:0.1:2.7
j=j+1;
T21(j)=0.333*cos(t)-0.245;
jT21=T21(j);
%jT21=0;
jT22=pi/2;%87°
jr23=3.1623;
jT23=4.391248;%248.5°
jT31=0;%0.226;%13°
jr32=3.1623;
jT32=1.8919369;%106°
jT33=1.5*pi;
jT11=1.106538;%62
jT12=0;
jT13=0;%01.5*pi+1.517
jT14=0;%0.226;
jT15=5.176646;%316°
for k=1:numel(T21)
x0=[jT11,jT12,jT13,jT14,jT15,jT22,jT23,jr23,jT31,jT32,jT33,jr32,jT21];
xsol=fsolve(@(x) funzz(x), [kT11,kT12,kT13,kT14,kT15,kT22,kT23,kr23,kT31,kT32,kT33,kr32,jT21]);
kT11=jxsol(1);
kT12=jxsol(2);
kT13=jxsol(3);
kT14=jxsol(4);
kT15=jxsol(5);
kT22=jxsol(6);
kT23=jxsol(7);
kr23=jxsol(8);
kT31=jxsol(9);
kT32=jxsol(10);
kT33=jxsol(11);
kr32=jxsol(12);
end
end
function F=funzz(x)
T11=x(1);
T12=x(2);
T13=x(3);
T14=x(4);
T15=x(5);
T22=x(6);
T23=x(7);
r23=x(8);
T31=x(9);
T32=x(10);
T33=x(11);
r32=x(12);
T21=x(13);
F(1)=(5^(0.5))*cos(T11)+cos(T12)+4*cos(T13)+cos(T14)+(5^(0.5))*cos(T15)-8;
F(2)=(5^(0.5))*sin(T11)+sin(T12)+4*sin(T13)+sin(T14)+(5^(0.5))*sin(T15);
F(3)=cos(T21)+3*cos(T22)+r23*cos(T23);
F(4)=sin(T21)+3*sin(T22)+r23*sin(T23);
F(5)=cos(T31)+r32*cos(T32)+3*cos(T33);
F(6)=sin(T31)+r32*sin(T32)+3*sin(T33);
F(7)=T12-T21;
F(8)=T31-T14;
F(9)=T13+T22-pi/2;
F(10)=T33-T22-pi;
F(11)=r23-(1+9+6*sin(T12-T13))^(0.5);
F(12)=r32-(1+9+6*cos(T14-T33))^(0.5);
end
But when I run it, it says:
Equation solved, fsolve stalled.
fsolve stopped because the relative size of the current step is less than the
default value of the step size tolerance and the vector of function values
is near zero as measured by the default value of the function tolerance.
<stopping criteria details>
Warning: Trust-region-dogleg algorithm of FSOLVE cannot handle non-square systems; using Levenberg-Marquardt
algorithm instead.
> In fsolve (line 310)
In wsadfg (line 30)
I saw that Levenberg-Marquardt is linked to options(is it right?), but i didn't understand how i can do.
Another thing, how can i make xsol a xsol(k)? Because matlab give me error if i put it.
Thank you in advance.
0 Comments
Accepted Answer
Matt J
on 14 Nov 2019
Edited: Matt J
on 14 Nov 2019
I know that i have to do fsolve(@(x) myfunz,x0,options)
I don't think so. The exit message says "Equation solved".
Another thing, how can i make xsol a xsol(k)?
for k=1:numel(T21)
xsol(:,k)=fsolve(@(x) funzz(x), [kT11,kT12,kT13,kT14,kT15,kT22,kT23,kr23,kT31,kT32,kT33,kr32,jT21]);
end
6 Comments
More Answers (0)
See Also
Categories
Find more on Line Plots 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!