From: Godzilla on
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.