查看单个帖子
旧 2019-12-10, 16:49   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
帖子 如何在MATLAB中将2X2矩阵转换为4X4矩阵?

我需要通过以下方式将2X2矩阵转换为4X4矩阵的一些帮助:

A = [2 6; 8 4] 应该变成:

B = [2 2 6 6; 2 2 6 6; 8 8 4 4; 8 8 4 4] 我该怎么做?


回答:
A = [2 6; 8 4]; % arbitrary 2x2 input matrix B = repmat(A,2,2); % replicates rows & columns but not in the way you want B = B([1 3 2 4], :); % swaps rows 2 and 3 B = B(:, [1 3 2 4]); % swaps columns 2 and 3, and you're done!

更多&回答...
poster 当前离线   回复时引用此帖