How to get back the original matrix with indices of matrix?

1 回表示 (過去 30 日間)
Ammy
Ammy 2021 年 8 月 21 日
コメント済み: Awais Saeed 2021 年 8 月 21 日
Let
A=reshape (1:16 ,4,4);
B1 = A(1:2:end, 1:2:end);
B2 = A(1:2:end, 2:2:end);
B3= A(2:2:end, 1:2:end);
B4 = A(2:2:end, 2:2:end);
How can I get back A with B1, B2,B3, and B4

採用された回答

Awais Saeed
Awais Saeed 2021 年 8 月 21 日
clc;clear all;close all
A=reshape (1:16 ,4,4); % 4x4 matrix
B1 = A(1:2:end, 1:2:end);
B2 = A(1:2:end, 2:2:end);
B3= A(2:2:end, 1:2:end);
B4 = A(2:2:end, 2:2:end);
c = reshape([B1 B2 B3 B4].', 4,4)';
c(:,[2,3]) = c(:,[3,2]) % swap columns
  2 件のコメント
Ammy
Ammy 2021 年 8 月 21 日
Thank you!
Awais Saeed
Awais Saeed 2021 年 8 月 21 日
you are welcome.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by