[英]permutations of vectors in matrix in matlab
I have a static matrix from a file: 我有一个文件的静态矩阵:
size(data)=[80 5]
What I want is to change position of each vector randomly when I use perms like: 我想要的是当我使用诸如以下的烫发时随机更改每个向量的位置:
N = size(data, 1);
X = perms(1:N); % # Permutations of column indices
Y = meshgrid(1:N, 1:factorial(N)); % # Row indices
idx = (X - 1) * N + Y; % # Convert to linear indexing
C = data(idx)
But its giving me an error: Maximum variable size allowed by the program is exceeded.
但是它给我一个错误:
Maximum variable size allowed by the program is exceeded.
Is there any other function to give me what I need? 还有其他功能可以满足我的需求吗?
perms
is not good for large numbers ie any number >10 perms
不适用于大数,即任何大于10的数
Refer the Documentation 请参阅文档
It says 它说
perms(v) is practical when length(v) is less than about 10.
当length(v)小于约10时,perms(v)很实用。
See the size it takes from the following code: 通过以下代码查看其大小:
MB(10,1) = 0;
for N = 1:10
X = perms(1:N);
dt=whos('X');
MB(N)=dt.bytes*9.53674e-7;
end
plot(1:10,MB,'r*-');
Note the sudden rise in the steepness of the curve beyond 9. 请注意,曲线的陡度突然超过9。
So i think im done 所以我认为我完成了
N = size(data, 1);
r=randperm(N);
for ii=1:80
matrix(r(ii),:) =data(ii,:) ;
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.