From: Juca on 30 Jul 2010 16:42 I'm newbie on matlab and I want to use lsqcurvefit to adjut 2 parameters, but this function is giving me a error that I coudn't solve. My function is, VEc=Vredm.*(((1-x).*K(1,1).*vass(1,1).*(X111-A1))+(x.*K(2,1).*vass(2,1).*(Y111-A2))+(((1-x).*KAB.*VassAB.*Y11 1.*(1-K(1,1).*X111))./((V(2,1)/V(1,1)).*(1-K(2,1).*Y111)+KAB.*Y111))); Vredm, x, X111, Y111 - 23 values each variable K, vass, V have - 2 values each variable A1, A2 - 1 value each variable KAB, VassAB - adjustable parameters When I give some values for KAB and VassAB, VEc runs OK, but when I use it in lsqcurvefit it give me this error, Error using ==> times Matrix dimensions must agree. Here is my lsqcurvefit function, [KAB,VassAB]=lsqcurvefit(@(KAB,VassAB) Vredm.*(((1-x).*K(1,1).*vass(1,1).*(X111-A1))+(x.*K(2,1).*vass(2,1).*(Y111-A2))+(((1-x).*KAB.*VassAB.*Y111.*( 1-K(1,1).*X111))./((V(2,1)/V(1,1)).*(1-K(2,1).*Y111)+KAB.*Y111))),[1,1],x,ve); Please somebody could help me with this function? Thanks in advanve.
From: Alan Weiss on 2 Aug 2010 14:38 I'm not sure, but I believe you did not construct your anonymous function properly. As you see in the lsqcurvefit function reference page http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/lsqcurvefit.html lsqcurvefit moves the values in your first argument (KAB), assuming VassAB is a fixed set of data. Take a look at the lsqcurvefit example http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brn4noo.html#brp3l6v-1 When you call lsqcurvefit you have to pass in xdata and ydata matrices. Did you do that? I don't see them in your function call. Good luck, Alan Weiss MATLAB mathematical toolbox documentation On 7/30/2010 4:42 PM, Juca wrote: > I'm newbie on matlab and I want to use lsqcurvefit to adjut 2 > parameters, but this function is giving me a > error that I coudn't solve. > > My function is, > > VEc=Vredm.*(((1-x).*K(1,1).*vass(1,1).*(X111-A1))+(x.*K(2,1).*vass(2,1).*(Y111-A2))+(((1-x).*KAB.*VassAB.*Y11 > > > 1.*(1-K(1,1).*X111))./((V(2,1)/V(1,1)).*(1-K(2,1).*Y111)+KAB.*Y111))); > > Vredm, x, X111, Y111 - 23 values each variable K, vass, V have - 2 > values each variable A1, A2 - 1 value each variable > KAB, VassAB - adjustable parameters > > When I give some values for KAB and VassAB, VEc runs OK, but when I use > it in lsqcurvefit it give me this > error, > > Error using ==> times > Matrix dimensions must agree. > > > Here is my lsqcurvefit function, > [KAB,VassAB]=lsqcurvefit(@(KAB,VassAB) > Vredm.*(((1-x).*K(1,1).*vass(1,1).*(X111-A1))+(x.*K(2,1).*vass(2,1).*(Y111-A2))+(((1-x).*KAB.*VassAB.*Y111.*( > > > 1-K(1,1).*X111))./((V(2,1)/V(1,1)).*(1-K(2,1).*Y111)+KAB.*Y111))),[1,1],x,ve); > > > Please somebody could help me with this function? > > Thanks in advanve.
From: Juca on 3 Aug 2010 13:57 Alan Weiss <aweiss(a)mathworks.com> wrote in message <i373br$k1u$1(a)fred.mathworks.com>... > I'm not sure, but I believe you did not construct your anonymous > function properly. As you see in the lsqcurvefit function reference page > http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/lsqcurvefit.html > lsqcurvefit moves the values in your first argument (KAB), assuming > VassAB is a fixed set of data. Take a look at the lsqcurvefit example > http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brn4noo.html#brp3l6v-1 > > When you call lsqcurvefit you have to pass in xdata and ydata matrices. > Did you do that? I don't see them in your function call. > > Good luck, > > Alan Weiss > MATLAB mathematical toolbox documentation > > On 7/30/2010 4:42 PM, Juca wrote: > > I'm newbie on matlab and I want to use lsqcurvefit to adjut 2 > > parameters, but this function is giving me a > > error that I coudn't solve. > > > > My function is, > > > > VEc=Vredm.*(((1-x).*K(1,1).*vass(1,1).*(X111-A1))+(x.*K(2,1).*vass(2,1).*(Y111-A2))+(((1-x).*KAB.*VassAB.*Y11 > > > > > > 1.*(1-K(1,1).*X111))./((V(2,1)/V(1,1)).*(1-K(2,1).*Y111)+KAB.*Y111))); > > > > Vredm, x, X111, Y111 - 23 values each variable K, vass, V have - 2 > > values each variable A1, A2 - 1 value each variable > > KAB, VassAB - adjustable parameters > > > > When I give some values for KAB and VassAB, VEc runs OK, but when I use > > it in lsqcurvefit it give me this > > error, > > > > Error using ==> times > > Matrix dimensions must agree. > > > > > > Here is my lsqcurvefit function, > > [KAB,VassAB]=lsqcurvefit(@(KAB,VassAB) > > Vredm.*(((1-x).*K(1,1).*vass(1,1).*(X111-A1))+(x.*K(2,1).*vass(2,1).*(Y111-A2))+(((1-x).*KAB.*VassAB.*Y111.*( > > > > > > 1-K(1,1).*X111))./((V(2,1)/V(1,1)).*(1-K(2,1).*Y111)+KAB.*Y111))),[1,1],x,ve); > > > > > > Please somebody could help me with this function? > > > > Thanks in advanve. Alan, I took a look at the documentation, changed my function and now it's working. You're right, the problem was my anonymous function. This is my new working function, [a]=lsqcurvefit(@(a,x) Vredm.*(((1-x).*K(1,1).*vass(1,1).*(X111-A1))+(x.*K(2,1).*vass(2,1).*(Y111-A2))+(((1-x).*a(1).*a(2).*Y111.*(1-K(1,1).*X111))./((V(2,1)/V(1,1)).*(1-K(2,1).*Y111)+a(1).*Y111))),[1,-5],x,ve,[1,-500],[100,-1]); Thanks for the help.
|
Pages: 1 Prev: regexp to read in string of negative and positive numbers Next: Finding a Matlab contractor |