Filter löschen
Filter löschen

How to get back the original matrix?

2 Ansichten (letzte 30 Tage)
Ammy
Ammy am 25 Mär. 2022
Beantwortet: Torsten am 25 Mär. 2022
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 Kommentare
KSSV
KSSV am 25 Mär. 2022
Already you have A...
Ammy
Ammy am 25 Mär. 2022
Yes But by the reverse process?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Torsten
Torsten am 25 Mär. 2022
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,:)

Weitere Antworten (1)

Chunru
Chunru am 25 Mär. 2022
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 Kommentar
Ammy
Ammy am 25 Mär. 2022
@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,:);

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by