MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   如何在MATLAB中将2X2矩阵转换为4X4矩阵? (https://www.labfans.com/bbs/showthread.php?t=22854)

poster 2019-12-10 16:49

如何在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!

[url=https://stackoverflow.com/questions/1643477]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 10:27

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.