小编Eri*_*345的帖子

Permuting columns of a matrix in MATLAB

Say I have an n by d matrix A and I want to permute the entries of some columns. To do this, I compute permutations of 1 ... n as

idx1 = randperm(n)'
idx2 = randperm(n)'
Run Code Online (Sandbox Code Playgroud)

Then I could do:

A(:,1) = A(idx1,1)
A(:,2) = A(idx2,2)
Run Code Online (Sandbox Code Playgroud)

However, I dont want to do this using a for-loop, as it'll be slow. Say I have an n by d matrix A and an n by d index matrix IDX that specifies …

random matlab permutation matrix vectorization

4
推荐指数
1
解决办法
216
查看次数

标签 统计

matlab ×1

matrix ×1

permutation ×1

random ×1

vectorization ×1