我用fsolve算非线性方程组出错,求大神指教。
Afficher commentaires plus anciens
function F=answer(x)
Ya=-300;Yb=300;Yc=-500;Zc=-450;Yd=500;Zd=-450;Theta=8;
F=[(x(1)-Ya)^2+x(2)^2-((Yc-Ya)^2+Zc^2);(x(3)-Yb)^2+x(4)^2-((Yd-Yb)^2+Zd^2);(x(1)-x(3))^2+(x(2)-x(4))^2-((Yc-Yd)^2+(Zc-Zd)^2);(x(2)-x(4))/(x(1)-x(3))-(tan(180*Theta/pi))];
end
x0=[1;2;3]
options=optimset('Display','iter');
[x,fval]=fsolve(@answer,x0,options)
Attempted to access x(4); index out of bounds because numel(x)=3.
Error in answer (line 3)
F=[(x(1)-Ya)^2+x(2)^2-((Yc-Ya)^2+Zc^2);(x(3)-Yb)^2+x(4)^2-((Yd-Yb)^2+Zd^2);(x(1)-x(3))^2+(x(2)-x(4))^2-((Yc-Yd)^2+(Zc-Zd)^2);(x(2)-x(4))/(x(1)-x(3))-(tan(180*Theta/pi))];
Error in fsolve (line 218)
fuser = feval(funfcn{3},x,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
如题,不知错误在哪里。。谢谢!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!