Results 1 to 3 of 3

Math Help - Matlab LSQ problem

  1. #1
    Junior Member
    Joined
    Apr 2009
    Posts
    70

    Matlab LSQ problem

    Hi

    i am trying to obtain to constants using 'lsqcurvefit' here's the code,

    xdata=stretch_r(:,2).';
    ydata=stress_r.';
    x0=[100; 1];
    [x,resnorm]=lsqcurvefit(@MooneyRivlin,x0,xdata,ydata)

    function F=MooneyRivlin(x,xdata)
    F=(2*x(1)+2*x(2)/xdata)*(xdata-1/xdata^2);


    Both 'stretch' and 'stress' are of length 14 but I keep getting the error,

    ??? Error using ==> optim\private\lsqncommon at 98
    LSQCURVEFIT cannot continue because user supplied objective function failed with the following error:
    Error using ==> mrdivide
    Matrix dimensions must agree.


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

    Error in ==> MonneyLSQ at 4
    [x,resnorm]=lsqcurvefit(@MooneyRivlin,x0,xdata,ydata)


    Any suggestions for this rather annoying error would be much appriciated thankyou.

    Nic
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Bwts View Post
    Hi

    i am trying to obtain to constants using 'lsqcurvefit' here's the code,

    xdata=stretch_r(:,2).';
    ydata=stress_r.';
    x0=[100; 1];
    [x,resnorm]=lsqcurvefit(@MooneyRivlin,x0,xdata,ydata)

    function F=MooneyRivlin(x,xdata)
    F=(2*x(1)+2*x(2)/xdata)*(xdata-1/xdata^2);


    Both 'stretch' and 'stress' are of length 14 but I keep getting the error,

    ??? Error using ==> optim\private\lsqncommon at 98
    LSQCURVEFIT cannot continue because user supplied objective function failed with the following error:
    Error using ==> mrdivide
    Matrix dimensions must agree.


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

    Error in ==> MonneyLSQ at 4
    [x,resnorm]=lsqcurvefit(@MooneyRivlin,x0,xdata,ydata)


    Any suggestions for this rather annoying error would be much appriciated thankyou.

    Nic
    I suspect you want the arithmetic operators to be element wise so try .* and ./ and .^ where appropriate

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Apr 2009
    Posts
    70
    Thankyou Captain it was indeed the operators.

    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Funny problem. What is cos(pi/2) in matlab?
    Posted in the Math Software Forum
    Replies: 8
    Last Post: January 29th 2010, 10:07 AM
  2. matlab problem
    Posted in the Math Software Forum
    Replies: 7
    Last Post: October 28th 2009, 08:09 AM
  3. MatLab IVP Problem
    Posted in the Math Software Forum
    Replies: 5
    Last Post: August 22nd 2009, 05:29 AM
  4. Matlab Problem For Help!
    Posted in the Math Software Forum
    Replies: 0
    Last Post: June 16th 2009, 05:15 PM
  5. MATLAB Problem
    Posted in the Math Software Forum
    Replies: 2
    Last Post: January 20th 2009, 06:42 AM

Search Tags


/mathhelpforum @mathhelpforum