Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: leastsqr problem
Date: Mon, 26 Oct 2009 20:19:06 +0000 (UTC)
Organization: University of Memphis
Lines: 40
Message-ID: <hc507q$6cp$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1256588346 6553 172.30.248.37 (26 Oct 2009 20:19:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 26 Oct 2009 20:19:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 233092
Xref: news.mathworks.com comp.soft-sys.matlab:580193


Anybody have experience with non-linear fitting, specifically using leasqr.m

Here is  my function:
%%% START
function y = leasqrfunc(x,px)
a = px(1);
b = px(2);
c = px(3);
p = px(4);

u = (x-c);

y = a + b./(u.^p);
%%% END 

and here is the partial derivative function (4 parameters);
%%% START
function y = leasqrdfdp(x,f,px,dp,func)
% function is y = a +  b/(x-c)^p
a = px(1);
b = px(2);
c = px(3);
p = px(4);

u = x-c;

y = [1.0 u.^(-p) b.*(-p).*(-1).*u.^(-p-1) b.*u.^(-p).*log(u).*(-1)];
% the above equation is all on one time
%%%%   END


The program complains about ;

??? Error using ==> horzcat
CAT arguments dimensions are not consistent.

Error in ==> leasqrdfdp 
y = [1.0 u.^(-p) b.*(-p).*(-1).*u.^(-p-1) b.*u.^(-p).*log(u).*(-1)];

I've used leasqr before without a hitch but now I can't seem to figure out what I'm doing wrong in the partial function.  I double checked the spaces between each partial and there are three spaces separating 4 partials, i.e.  one for each parameter.