Random selection of matrix columns

I have a mxn matrix and I want to use it in some neural network applications in MATLAB.

For instance,

 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 check the rest of the remaining columns. So, the first matrix will contain three random separate columns taken from the original matrix A, while the second matrix contains the remaining two columns.

How can I extract these matrices?

+6
source share
2 answers

This will do:

 s = randperm(5); train = A(:, s(1:3)); test = A(:, s(4:end)); 
+8
source

The Neural Network Toolbox comes with a set of features that do this for you, such as dividerand and divideblock .

+1
source

Source: https://habr.com/ru/post/901882/


All Articles