I have a question. Suppose I have matrix A =
1 2 3
4 5 6
7 8 9
10 11 12
I need to select n rolling rows from A and transpose elements in new matrix C in rows. The loop that I use is:
n = 3; %for instance every 3 rows of A
B = [];
for i = 1:n
Btemp = transpose(A(i:i+size(A,1)-n,:));
B = [B;Btemp];
end
C=B ;
并产生矩阵C,即:
C =
1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 10 11 12
这就是我也想要做的, 但我可以做同样的工作 没有循环?
计算一个3280x35大小的A矩阵需要4分钟。