|
"Jason" wrote in message <k2am3v$5uj$1@newscl01ah.mathworks.com>...
> I have a 3d array of data. Each [row,col] represents a measurement with the results in the 3d dimension (call it the Z dimension).
>
> I want to perform a lsqcurvefit on each [row,col,:] (1 x 1 x Z). I'm currently doing the following
> for ii = 1:nRows
> for jj = 1:nCols
> TC(ii,jj) = lsqcurvefit(@model,1,Xdata,squeeze(Data(ii,jj,:))',0,10,Options);
> end
> end
==================
What you say you're doing above doesn't seem possible. You're assigning the output of lsqcurvefit, a vector, to the scalar location TC(ii,jj). The code should be giving you errors. Nevertheless, below is an approach using ARRAYFUN,
[ii,jj]=ndgrid(1:nRows,1:nCols);
p=numel(ii);
fun=@(k) lsqcurvefit(@model,1,Xdata,squeeze(Data(ii(k),jj(k),:))',0,10,Options);
Tcell=arrayfun(fun,1:p,'UniformOutput',0);
Tcell=reshape(Tcell,size(ii));
|