随机选择矩阵列 [英] Random selection of matrix columns

查看:114
本文介绍了随机选择矩阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个m x n矩阵,我想在MATLAB的某些神经网络应用程序中使用它.

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

例如,

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

我想随机训练一些列,并测试其余的列. 因此,第一个矩阵将包含三个取自原始矩阵A的随机且不同的列,而第二个矩阵将包含其余两列.

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.

如何提取这些矩阵?

推荐答案

这可以做到:

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

这篇关于随机选择矩阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆