[英]Matlab: selecting non-consecutive matrix columns
I've got a 28 x 28 x 1 x 10000 matrix called data
and a 1 x 10000 vector called labels
, which consists of a bunch of integers from 0 - 9. What I'd really like to do is split the data
matrix into 10 smaller matrices, corresponding to the label
values. 我有一个28 x 28 x 1 x 10000矩阵称为data
和一个1 x 10000矢量称为labels
,它由一组0到9的整数组成。我真正想做的是将data
矩阵分成10个较小的矩阵,对应于label
值。
Is there any way to do this other than a for loop? 除了for循环之外,还有什么方法可以做到这一点吗?
Matlab allows slice indexing. Matlab允许切片索引。 For example: 例如:
data(:,:,:,1:1000)
I can't see how you're getting "non-consecutive". 我看不出你是如何“非连续”的。 There's a hint there of selecting on the label, but the dimensions don't match. 在标签上有一个选择的提示,但尺寸不匹配。 If they did: 如果他们这样做:
data(:,:,:,label == 1)
or 要么
data(:,:,:,find(label == 1))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.