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

Thread Subject:
curve fitting

Subject: curve fitting

From: Snow White

Date: 15 May, 2009 14:32:01

Message: 1 of 5

hello,

i tried the following code:

 B = lsqcurvefit(@polsin,A,polang,intensityy,[0 -255 -2*pi],[255 255 2*pi],optimset('Display','off'));

and got this error

??? Error using ==> lsqncommon at 134
Function value and YDATA sizes are incommensurate.

Error in ==> lsqcurvefit at 186
[x,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...

Error in ==> newnew at 164
            B = lsqcurvefit(@polsin,A,polang,intensityy,[0 -255 -2*pi],[255 255
            2*pi],optimset('Display','off'));
bye

Subject: curve fitting

From: Steven Lord

Date: 15 May, 2009 17:43:36

Message: 2 of 5


"Snow White" <gulesaman@gmail.com> wrote in message
news:gujud1$fr9$1@fred.mathworks.com...
> hello,
>
> i tried the following code:
>
> B = lsqcurvefit(@polsin,A,polang,intensityy,[0 -255 -2*pi],[255 255
> 2*pi],optimset('Display','off'));
>
> and got this error
>
> ??? Error using ==> lsqncommon at 134
> Function value and YDATA sizes are incommensurate.

The reference page for LSQCURVEFIT:

http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/lsqcurvefit.html

says, in part:

"lsqcurvefit requires a user-defined function to compute the vector-valued
function F (x, xdata). The size of the vector returned by the user-defined
function must be the same as the size of the vectors ydata and xdata."

Does your polsin function satisfy that requirement? My guess is that it
does not. Fix it so it does.

--
Steve Lord
slord@mathworks.com

Subject: curve fitting

From: Snow White

Date: 18 May, 2009 11:34:13

Message: 3 of 5

I checked the sized of the variables they are as follows:

size(intensityy)

ans =

     1 1 19
size(polang)

ans =

    19 1
size(A)

ans =

     1 3

how do i fix it ?

"Steven Lord" <slord@mathworks.com> wrote in message <guk9k4$1s4$1@fred.mathworks.com>...
>
> "Snow White" <gulesaman@gmail.com> wrote in message
> news:gujud1$fr9$1@fred.mathworks.com...
> > hello,
> >
> > i tried the following code:
> >
> > B = lsqcurvefit(@polsin,A,polang,intensityy,[0 -255 -2*pi],[255 255
> > 2*pi],optimset('Display','off'));
> >
> > and got this error
> >
> > ??? Error using ==> lsqncommon at 134
> > Function value and YDATA sizes are incommensurate.
>
> The reference page for LSQCURVEFIT:
>
> http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/lsqcurvefit.html
>
> says, in part:
>
> "lsqcurvefit requires a user-defined function to compute the vector-valued
> function F (x, xdata). The size of the vector returned by the user-defined
> function must be the same as the size of the vectors ydata and xdata."
>
> Does your polsin function satisfy that requirement? My guess is that it
> does not. Fix it so it does.
>
> --
> Steve Lord
> slord@mathworks.com
>

Subject: curve fitting

From: Steven Lord

Date: 18 May, 2009 13:35:03

Message: 4 of 5


"Snow White" <gulesaman@gmail.com> wrote in message
news:gurh3l$8v3$1@fred.mathworks.com...
>I checked the sized of the variables they are as follows:
>
> size(intensityy)
>
> ans =
>
> 1 1 19
> size(polang)
>
> ans =
>
> 19 1

Your XDATA and YDATA inputs to LSQCURVEFIT are not the same size. Therefore
I'm guessing the output from your polsin objective function is probably the
same size as the XDATA (polang) which is not the same size as your YDATA
(intensityy). You'll need to make sure that it is. SQUEEZEing intensityy
before calling LSQCURVEFIT will probably work.

--
Steve Lord
slord@mathworks.com

Subject: curve fitting

From: Snow White

Date: 18 May, 2009 14:50:02

Message: 5 of 5

Thank you!

it works for one time only!

the size of intensity is growing despite clearing intensityy...
in the second un it is 1 38 although it shud be 1 19 any suggestion ?:S


"Steven Lord" <slord@mathworks.com> wrote in message <guro61$bba$1@fred.mathworks.com>...
>
> "Snow White" <gulesaman@gmail.com> wrote in message
> news:gurh3l$8v3$1@fred.mathworks.com...
> >I checked the sized of the variables they are as follows:
> >
> > size(intensityy)
> >
> > ans =
> >
> > 1 1 19
> > size(polang)
> >
> > ans =
> >
> > 19 1
>
> Your XDATA and YDATA inputs to LSQCURVEFIT are not the same size. Therefore
> I'm guessing the output from your polsin objective function is probably the
> same size as the XDATA (polang) which is not the same size as your YDATA
> (intensityy). You'll need to make sure that it is. SQUEEZEing intensityy
> before calling LSQCURVEFIT will probably work.
>
> --
> Steve Lord
> slord@mathworks.com
>

Tags for 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