From: Els on 30 May 2010 03:19 I try to solve a couple of nonlinear equations with the following function -------------------- function F = SolveNG(x,cx,cy,cz,ax,ay,az,P4,P5,CP) n = cross(P4-CP',P4-P5); n = n(:).'/norm(n) D1 = -n(1,1)*P4(1,1) - n(1,2)*P4(1,2) - n(1,3)*P4(1,3) P1=P4(1,1); P2=P4(1,2); P3=P4(1,3); N1=n(1,1) N2=n(1,2) N3=n(1,3) F = [N1*x(1) + N2*x(2) + N3*x(3) + D1; ((x(1)-cx)/ax)^2 + ((x(2)-cy)/ay)^2 + ((x(3)-cz)/az)^2 -1; ((2*(x(1)-cx))/(ax^2))- x(4); ((2*(x(2)-cy))/(ay^2))- x(5); ((2*(x(3)-cz))/(az^2))- x(6); x(4)*x(1) + x(5)*x(2) + x(6)*x(3)+ x(7); x(4)*P1 + x(5)*P2 + x(6)*P3+ x(7)]; end ------------------- In the main function I use this code to call my function ------------------- x0 = [-80; -40; -40;-30;-30;-30;-30]; % Make a starting guess at the solution options=optimset('Display','iter'); % Option to display output fsolve(@SolveNG, x0, options, cx,cy,cz,ax,ay,az,P4,P5,CP) ------------------ But I get an error which I do not understand: ??? Error using ==> vertcat CAT arguments dimensions are not consistent. Error in ==> SolveNG at 12 F = [N1*x(1) + N2*x(2) + N3*x(3) + D1; Error in ==> fsolve at 253 fuser = feval(funfcn{3},x,varargin{:}); Error in ==> TestSimpeSphere at 726 fsolve(@SolveNG, x0, options, cx,cy,cz,ax,ay,az,P4,P5,CP) Caused by: Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue. How can I solve this??
From: Bruno Luong on 30 May 2010 04:22 > > How can I solve this?? Set a breakpoint in your function and check the size of the variables when it's invoked. Bruno
From: Els on 30 May 2010 05:29 x is a 7x1 sized variable, which should be correct, because there are 7 equations as well. Still the error keeps coming when the F= line comes.
From: Els on 30 May 2010 06:15 Bruno, maybe a quick look to my constants can help you determine where the problem is. % cx = -27.6359; % cy = 15.4697; % cz = -11.3979; % ax = 21.1604; % ay = 21.1604; % az = 21.1604; % P4 = [-35.3578 33.0654 10.1122]; % P5 = [ -60.2000 -33.1000 -46.8000]; % CP = [-47.8215;11.6973;-6.2917]; Is it possible that the error comes from a wrong chosen x0?
From: Bruno Luong on 30 May 2010 06:18 "Els " <y.e.t.reeuwijk(a)student.utwente.nl> wrote in message <httb52$mgd$1(a)fred.mathworks.com>... > x is a 7x1 sized variable, Fine, but I wrote "variables" (plurial). Bruno
|
Next
|
Last
Pages: 1 2 3 Prev: I am also getting this error Next: Welch spectrum using Hamming window |