extracting value from a vector
Alain Baeckeroot
alain.baeckeroot at laposte.net
Tue Apr 21 13:19:57 CDT 2009
Le 21/04/2009 à 19:21, John W. Eaton écrit :
>
> On 21-Apr-2009, Rob Mahurin wrote:
>
> | I want this often enough that I've written
> |
> | function varargout = columns_of (in)
> | [d1,d2] = size(in);
> | varargout = mat2cell(in, d1, ones(1,d2) );
> | endfunction
> |
> | so I can do e.g.
> |
> | octave> v = rand(2,3), [a,b] = columns_of(v)
> | v =
> | 0.054753 0.509675 0.866045
> | 0.702775 0.483820 0.816340
> | a =
> | 0.054753
> | 0.702775
> | b =
> | 0.50968
> | 0.48382
>
> See also num2cell, {:}, and deal:
>
> v = rand (2, 3), [a, b, c] = deal (num2cell (v, 1){:})
>
> However, unlike your function, deal requires nargout == nargin.
>
> jwe
>
>
thanks, now i know the adequate octave function, and hand made ones,
which are better than what i wrote :-)
Alain.
More information about the Help-octave
mailing list