Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Random selection of matrix columns

I have an m x n matrix and I want to use it in some neural networks applications in MATLAB.

For example,

A = [ 24 22 35 40 30 ; 32 42 47 45 39 ; 14 1 10 5 9 ; 2 8 4 1 8] ;

I want to randomly train some columns and test the other remaining columns. So, the first matrix will contain three random, distinct columns taken from the original matrix A, while the second matrix contains the remaining two columns.

How can I extract these matrices ?

like image 525
user488182 Avatar asked Nov 19 '11 11:11

user488182


1 Answers

This will do:

s = randperm(5); 
train = A(:, s(1:3));
test = A(:, s(4:end));
like image 85
Ali Avatar answered Nov 06 '22 00:11

Ali