Reply by Felipe Giraldo May 27, 20082008-05-27
Try this:

X = [2     3     4     1;
       8     7     6     2;
       1     2     5     7;
       4     7     2     3];

random_index = randperm(4);    % >> help randperm
Y1 = X(random_index(1:2), : );
Y2 = X(random_index(3:4), : );

Best regards,

LF
--- El mar 27-may-08, Cagin Kandemir Cavas <c...@hotmail.com> escribió:
De: Cagin Kandemir Cavas <c...@hotmail.com>
Asunto: [matlab] random row sampling
A: m...
Fecha: martes, 27 mayo, 2008, 3:12 am

Hi all,

Suppose I have a matrix X as follows,

2 3 4 1 8 7 6 2 1 2 5 7 4
7 2 3

Then how should I write a code to sample two row ramdomly (called Y) from that
matrix. At last, I must have two matrix; X matrix must become 2x4 (with
remaining row after sampling) and Y matrix (2x4). Please help me as soon as
possible. Thanks in advance,
Reply by arkkimede May 27, 20082008-05-27
Your question can break in two part.
1) Make a sample random is equivalent to make a permutation of the vector
2) You can reshape the vector in two colums

Example:

% The number of elements must be even
x = [2 4 7 9 4 3 6 8 4 7];
N = length(x)
new_index = randperm(N);

y = x(new_index);

newy = reshape(y,2,N/2);

On Tue, May 27, 2008 at 10:12 AM, Cagin Kandemir Cavas <
c...@hotmail.com> wrote:

> Hi all,
>
> Suppose I have a matrix X as follows,
>
> 2 3 4 1 8 7 6 2 1 2 5 7
> 4 7 2 3
>
> Then how should I write a code to sample two row ramdomly (called Y) from
> that matrix. At last, I must have two matrix; X matrix must become 2x4 (with
> remaining row after sampling) and Y matrix (2x4). Please help me as soon as
> possible. Thanks in advance,
>
Reply by Cagin Kandemir Cavas May 27, 20082008-05-27
Hi all,

Suppose I have a matrix X as follows,

2 3 4 1 8 7 6 2 1 2 5 7 4 7 2 3

Then how should I write a code to sample two row ramdomly (called Y) from that matrix. At last, I must have two matrix; X matrix must become 2x4 (with remaining row after sampling) and Y matrix (2x4). Please help me as soon as possible. Thanks in advance,