[英]permutations of vectors in matrix in matlab
我有一個文件的靜態矩陣:
size(data)=[80 5]
我想要的是當我使用諸如以下的燙發時隨機更改每個向量的位置:
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)
但是它給我一個錯誤: Maximum variable size allowed by the program is exceeded.
還有其他功能可以滿足我的需求嗎?
perms
不適用於大數,即任何大於10的數
請參閱文檔
它說
當length(v)小於約10時,perms(v)很實用。
通過以下代碼查看其大小:
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*-');
請注意,曲線的陡度突然超過9。
所以我認為我完成了
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.