Home > Archive > Matlab > May 2005 > Re: Cell arrays, more elegantly (addendum)
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: Cell arrays, more elegantly (addendum)
|
|
| Mat Cross 2005-05-28, 3:59 pm |
| Perhaps the varargout stuff obscures my main question. For the purposes of
this example I'm assuming that nargout = 5. I think my problem comes down to
whether or not the use of deal can be combined with array indexing. I don't
really want to have to form a string with a variable amount of entries and
then plug that into deal: I don't really want to have
? = deal(x_1,x_2,...,x_k)
with the argument string made from a for loop.
Can I do something like
X = [x_1, x_2, ... x_k]
? = deal(X(column 1:column k))
or
? = deal(X)(column 1:column k)
| |
| Loren Shure 2005-05-31, 4:05 pm |
| In article <d79li4$17tl$1@godfrey.mcc.ac.uk>, mcross@ma.man.ac.uk
says...
> Perhaps the varargout stuff obscures my main question. For the purposes of
> this example I'm assuming that nargout = 5. I think my problem comes down to
> whether or not the use of deal can be combined with array indexing. I don't
> really want to have to form a string with a variable amount of entries and
> then plug that into deal: I don't really want to have
> ? = deal(x_1,x_2,...,x_k)
> with the argument string made from a for loop.
> Can I do something like
> X = [x_1, x_2, ... x_k]
> ? = deal(X(column 1:column k))
> or
> ? = deal(X)(column 1:column k)
>
>
>
Make X a cell array:
X = {x_1 x_2 ... x_k}
Then, in R14, you don't even need to use deal. You can simply do this:
varargout(1:length(X)) = X{:};
and that will distribute the results.
--Loren
|
|
|
|
|