[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: extracting value from a vector
From: 
John W. Eaton 
Subject: 
Re: extracting value from a vector 
Date: 
Tue, 21 Apr 2009 13:21:41 0400 
On 21Apr2009, 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
 extracting value from a vector, Alain Baeckeroot, 2009/04/21
 Re: extracting value from a vector, James Sherman Jr., 2009/04/21
 Re: extracting value from a vector, Rob Mahurin, 2009/04/21
 Re: extracting value from a vector,
John W. Eaton <=
 Re: extracting value from a vector, Alain Baeckeroot, 2009/04/21
 Re: extracting value from a vector, Rob Mahurin, 2009/04/21
 Re: extracting value from a vector, John W. Eaton, 2009/04/21
 Re: extracting value from a vector, Rob Mahurin, 2009/04/21
 Re: extracting value from a vector, John W. Eaton, 2009/04/21
 Re: extracting value from a vector, Przemek Klosowski, 2009/04/23