extracting rows in a matrix

Ben Abbott bpabbott at mac.com
Tue May 12 18:13:00 CDT 2009


On May 12, 2009, at 6:03 PM, Carlo Rossi wrote:

> Hello,
>  I have a matrix A 450x10  and I need t extract randomly 1/5 of 500  
> rows and create with these rows another matrix B.
> Is there any function to do it? Any helps?
>
> thanks,

You can do that in one line, but using "randperm" and Octave's cool  
method for indexing.

	B = A(randperm (size (A, 1)), :)(1:size (A, 1)/5, :);

Ben


More information about the Help-octave mailing list