Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Thread Subject:
Error in fsolve: CAT arguments dimensions are not consistent

Subject: Error in fsolve: CAT arguments dimensions are not consistent

From: Els

Date: 28 May, 2010 13:33:23

Message: 1 of 1

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)

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)];

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??

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us