通信矩阵定义为: https://en.wikipedia.org/wiki/Commutation_matrix
假设我有矩阵
A = [1,2,3;4,5,6];
如何在MATLAB中获取交换矩阵?
答案 0 :(得分:3)
不确定它是否在“作弊”,但是您可以尝试:
[m, n] = size(A);
I = reshape(1:m*n, [m, n]); % initialize a matrix of indices of size(A)
I = I'; % Transpose it
I = I(:); % vectorize the required indices
Y = eye(m*n); % Initialize an identity matrix
Y = Y(I,:); % Re-arrange the rows of the identity matrix
那么换向矩阵就是Y。