How to get back the original matrix?

조회 수: 4 (최근 30일)
Ammy
Ammy 2022년 3월 25일
답변: Torsten 2022년 3월 25일
A=[1 2 3 2;4 1 2 3;3 4 3 2;2 4 1 1];
>> R=[1 3 4 2];
>> B=A(R,:);
>> C=B(:)';
>> D=[1 0 0 1 0 1 0 1 0 1 0 0 1 1 0 1];
>> E=C(D==1);
Can we get back A?
  댓글 수: 2
KSSV
KSSV 2022년 3월 25일
Already you have A...
Ammy
Ammy 2022년 3월 25일
Yes But by the reverse process?

댓글을 달려면 로그인하십시오.

채택된 답변

Torsten
Torsten 2022년 3월 25일
A = [1 2 3 2;...
4 1 2 3;...
3 4 3 2;...
2 4 1 1]
R = [1 3 4 2];
B = A(R,:);
Rinv(R) = 1:numel(R);
A_recovered = B(Rinv,:)

추가 답변 (1개)

Chunru
Chunru 2022년 3월 25일
A=[1 2 3 2;4 1 2 3;3 4 3 2;2 4 1 1];
% Reordering the rows of A is reversible
R=[1 3 4 2];
B=A(R,:);
% Straightening up the matrix into vector is also reversible
C=B(:)';
% Picking up part of the data is not reversible
D=[1 0 0 1 0 1 0 1 0 1 0 0 1 1 0 1];
E=C(D==1);
  댓글 수: 1
Ammy
Ammy 2022년 3월 25일
@Chunru thank you
How the following can be
reversible ,
A=[1 2 3 2;4 1 2 3;3 4 3 2;2 4 1 1];
% Reordering the rows of A is reversible
R=[1 3 4 2];
B=A(R,:);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by