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:
Incommensurate error in LSQcurvefit?

Subject: Incommensurate error in LSQcurvefit?

From: Nic Roberts

Date: 12 Jul, 2011 21:58:10

Message: 1 of 3

Hi,

I using lsqcurvefit but I keep getting an error saying that,

"Function value and YDATA sizes are incommensurate."

My problem is that the function value vector is exactly the same size as the YDATA value. So what else could the problem be?

Code snippet from function

for i=1:length(xdata)
    p=x(1)+x(2)*(F_11(i)^2+F_22(i)^2);
    Moon11=x(1)+x(2)*(F_22(i)^2+1/(F_11(i)^2*F_22(i)^2));
    Moon22=x(1)+x(2)*(F_11(i)^2+1/(F_11(i)^2*F_22(i)^2));
      if(F_11(i)<C_lambdaT)
        Walpha=x(3)*x(4)*exp((x(4)/2)*(F_11(i)^2-1));
        S11x(i)=Moon11+Walpha-p;
     else
         Walpha=x(3)*x(4)*exp((x(4)/2)*(C_lambdaT^2-1));
         S11x(i)=Walpha+C_grad*F_11(i)+C_inter;
     end
     if(F_22(i)<R_lambdaT)
        Wbeta=x(5)*x(6)*exp((x(6)/2)*(F_22(i)^2-1));
        S22x(i)=Moon22+Wbeta-p;
     else
         Wbeta=x(5)*x(6)*exp((x(6)/2)*(R_lambdaT^2-1));
         S22x(i)=Wbeta+R_grad*F_22(i)+R_inter;
     end
end

Ein=[S11x S22x];

Where length(xdata)=length(ydata) and Ein is the function value.

Thanks for any help with this. I have used this function before with a different data set and it worked fine.

Nic

Subject: Incommensurate error in LSQcurvefit?

From: Torsten

Date: 13 Jul, 2011 06:45:54

Message: 2 of 3

On 12 Jul., 23:58, "Nic Roberts" <efy2...@leeds.ac.uk> wrote:
> Hi,
>
> I using lsqcurvefit but I keep getting an error saying that,
>
> "Function value and YDATA sizes are incommensurate."
>
> My problem is that the function value vector is exactly the same size as the YDATA value. So what else could the problem be?
>
> Code snippet from function
>
> for i=1:length(xdata)
>     p=x(1)+x(2)*(F_11(i)^2+F_22(i)^2);
>     Moon11=x(1)+x(2)*(F_22(i)^2+1/(F_11(i)^2*F_22(i)^2));
>     Moon22=x(1)+x(2)*(F_11(i)^2+1/(F_11(i)^2*F_22(i)^2));
>       if(F_11(i)<C_lambdaT)
>         Walpha=x(3)*x(4)*exp((x(4)/2)*(F_11(i)^2-1));
>         S11x(i)=Moon11+Walpha-p;
>      else
>          Walpha=x(3)*x(4)*exp((x(4)/2)*(C_lambdaT^2-1));
>          S11x(i)=Walpha+C_grad*F_11(i)+C_inter;
>      end
>      if(F_22(i)<R_lambdaT)
>         Wbeta=x(5)*x(6)*exp((x(6)/2)*(F_22(i)^2-1));
>         S22x(i)=Moon22+Wbeta-p;
>      else
>          Wbeta=x(5)*x(6)*exp((x(6)/2)*(R_lambdaT^2-1));
>          S22x(i)=Wbeta+R_grad*F_22(i)+R_inter;
>      end
> end
>
> Ein=[S11x S22x];
>
> Where length(xdata)=length(ydata) and Ein is the function value.
>
> Thanks for any help with this. I have used this function before with a different data set and it worked fine.
>
> Nic


The length of "Ein" must be equal to the length of YDATA, but
length(EIN) = 2*length(YDATA) ...

Best wishes
Torsten.

Subject: Incommensurate error in LSQcurvefit?

From: Nic Roberts

Date: 13 Jul, 2011 09:33:08

Message: 3 of 3

Torsten <Torsten.Hennig@umsicht.fraunhofer.de> wrote in message <e1bd8c6b-afd7-4313-aa9f-e38ae971d375@u28g2000yqf.googlegroups.com>...
> On 12 Jul., 23:58, "Nic Roberts" <efy2...@leeds.ac.uk> wrote:
> > Hi,
> >
> > I using lsqcurvefit but I keep getting an error saying that,
> >
> > "Function value and YDATA sizes are incommensurate."
> >
> > My problem is that the function value vector is exactly the same size as the YDATA value. So what else could the problem be?
> >
> > Code snippet from function
> >
> > for i=1:length(xdata)
> >     p=x(1)+x(2)*(F_11(i)^2+F_22(i)^2);
> >     Moon11=x(1)+x(2)*(F_22(i)^2+1/(F_11(i)^2*F_22(i)^2));
> >     Moon22=x(1)+x(2)*(F_11(i)^2+1/(F_11(i)^2*F_22(i)^2));
> >       if(F_11(i)<C_lambdaT)
> >         Walpha=x(3)*x(4)*exp((x(4)/2)*(F_11(i)^2-1));
> >         S11x(i)=Moon11+Walpha-p;
> >      else
> >          Walpha=x(3)*x(4)*exp((x(4)/2)*(C_lambdaT^2-1));
> >          S11x(i)=Walpha+C_grad*F_11(i)+C_inter;
> >      end
> >      if(F_22(i)<R_lambdaT)
> >         Wbeta=x(5)*x(6)*exp((x(6)/2)*(F_22(i)^2-1));
> >         S22x(i)=Moon22+Wbeta-p;
> >      else
> >          Wbeta=x(5)*x(6)*exp((x(6)/2)*(R_lambdaT^2-1));
> >          S22x(i)=Wbeta+R_grad*F_22(i)+R_inter;
> >      end
> > end
> >
> > Ein=[S11x S22x];
> >
> > Where length(xdata)=length(ydata) and Ein is the function value.
> >
> > Thanks for any help with this. I have used this function before with a different data set and it worked fine.
> >
> > Nic
>
>
> The length of "Ein" must be equal to the length of YDATA, but
> length(EIN) = 2*length(YDATA) ...
>
> Best wishes
> Torsten.

Thanks fo rthe reply Torsten. I tracked the problem down I needed to transpose YDATA now it works fine.

Nic

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