extracting rows in a matrix
Carlo Rossi
serosole at yahoo.it
Wed May 13 08:20:22 CDT 2009
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 <bpabbott at mac.com> ha scritto:
Da: Ben Abbott <bpabbott at mac.com>
Oggetto: Re: extracting rows in a matrix
A: serosole at yahoo.it
Cc: help-octave at octave.org
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www-old.cae.wisc.edu/pipermail/help-octave/attachments/20090513/afb9aba9/attachment.html
More information about the Help-octave
mailing list