help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: extracting rows in a matrix


From: Carlo Rossi
Subject: Re: extracting rows in a matrix
Date: Wed, 13 May 2009 13:20:22 +0000 (GMT)

this is very cool but actually I need to write something that is good for Matlab too; and I notice only now that it doens't work in Matlab
-
thanks

--- Mer 13/5/09, Ben Abbott <address@hidden> ha scritto:

Da: Ben Abbott <address@hidden>
Oggetto: Re: extracting rows in a matrix
A: address@hidden
Cc: address@hidden
Data: Mercoledì 13 maggio 2009, 01:13


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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]