Solving 8-equations system in 8 variables with lsqnonlin()
Show older comments
Hi I'm trying to use lsqnonlin with this system:
'file.m' if true % code
function y = prova_in_s(x,Sm,S_std,g_m,g_l)
T1=tras_scatter_par(Sm(:,1:2)); T_std1=tras_scatter_par(S_std(:,1:2)); S_probe=[x(1)+i*x(5),x(2)+i*x(6);x(3)+i*x(7),x(4)+i*x(8)]; T_probe=tras_scatter_par(S_probe);
parz=[real(T_probe*T_std1*T_probe-T1); imag(T_probe*T_std1*T_probe-T1)];
if numel(Sm)>4 T2=tras_scatter_par(Sm(:,3:4)); T_std2=tras_scatter_par(S_std(:,3:4));
parz2=[real(T_probe*T_std2*T_probe-T2); imag(T_probe*T_std2*T_probe-T2)];
% parz2=[real(T_probe*T_std2); % imag(T_probe*T_std2)]; %
end
for cicles=1:numel(g_m) loadst(cicles)=(g_l(cicles)*(T_probe(1,2))/(T_probe(1,1))+1)*g_m(cicles)-g_l(cicles)*det(T_probe)*(T_probe(2,2))/(T_probe(1,1))-((T_probe(2,1))/(T_probe(1,1))); end
for cicles=1:numel(g_m) if cicles==1 parz_load=[real(loadst(cicles));imag(loadst(cicles))]; else parz_load=[parz_load;real(loadst(cicles));imag(loadst(cicles))]; end end
y1=[parz(1);parz(2);parz(3);parz(4);parz(5);parz(6);parz(7);parz(8);parz_load];
y2=[parz(1);parz(2);parz(3);parz(4);parz(5);parz(6);parz(7);parz(8)];
if numel(Sm)>4 y=[y1;y2]; else y=y1;
end end
The problem consists in:
varyng the coefficients of the equations the solver calculate a wrong solution with an error of 20-30 % from the real solution. I thought that a reason is that the solution is not unique...so the choose of the intial guess, x0, is fundamental...i could adjust the FunTol too..anyway i call lsqnonlin in this form: " [x_sol,resnorm] = lsqnonlin(@(x)prova_in_s(x,a,b,c,gamma_std),x0,lbo,ubo); " how can i adjust FunTol? if I try to pass the option structure it return me an error. I read also thet optimset is not valid for lsqnonlin, so how i can adjust the options like algorithm etc.. Thank you in advance for your help.
Accepted Answer
More Answers (0)
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!