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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by