From: Armin Mueller on
Dear NG,

I would like to fit a number of vectors p and y. They have different
lengths, so they are stored in cells. Now, how can I store the
individual results? Obviously, this example doesn't work since the
result "cf" is of type "cfit". "gof" and "out" are structures which is OK.

for idx = 1:100
[cf(idx), gof(idx), out(idx)] = fit(y{idx}, p{idx}, fittype('gauss1'));
end

Do I have to build a cell array of type "cfit"? How to do this?!

Thank you for any hint!
Armin
From: Steven Lord on

"Armin Mueller" <arm.in(a)web.de> wrote in message
news:hs9kud$o3o$1(a)news2.rz.uni-karlsruhe.de...
> Dear NG,
>
> I would like to fit a number of vectors p and y. They have different
> lengths, so they are stored in cells. Now, how can I store the individual
> results? Obviously, this example doesn't work since the result "cf" is of
> type "cfit". "gof" and "out" are structures which is OK.
>
> for idx = 1:100
> [cf(idx), gof(idx), out(idx)] = fit(y{idx}, p{idx},
> fittype('gauss1'));
> end
>
> Do I have to build a cell array of type "cfit"? How to do this?!

Basically the same way you created p and y.

cf = cell(1, 100);
gof = cell(1, 100);
out = cell(1, 100);
for idx = 1:100
[cf{idx}, gof{idx}, ...
end

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Armin Mueller on
Steven Lord wrote:

>> Do I have to build a cell array of type "cfit"? How to do this?!
>
> Basically the same way you created p and y.
>
> cf = cell(1, 100);
>[...]

This was almost too easy. I'm feeling ashamed. Thank you Steven!

;-)
Armin