can we find the original matrix back from the modified matrix whose rows were initially swapped .
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
hi.... please solve my problem I have a matrix A of size say mxn. The rows of matrix A are swapped(interchanged) and found a matrix B. Swapping of the rows is done according to the values already given in form of two vectors. Can we reconstruct the original matrix A from matrix B. For reconstructing no vectors are given.
3 Kommentare
Antworten (2)
Jos (10584)
am 14 Okt. 2016
So you know B and the vector v that contains the two rows where swapped to create A. Then it is easy:
A = magic(5)
v = [2 3] % swap row 2 and 3
% construct B, (this could be done simpler, see reconstruction method)
B = A ;
B(v(1),:) = A(v(2),:) ;
B(v(2),:) = A(v(1),:) ;
% reconstruct A
A2 = B ;
A2(v,:) = B(v([2 1]),:) ;
isequal(A,A2) % success!
0 Kommentare
Steven Lord
am 14 Okt. 2016
I have a standard deck of 52 playing cards in some arbitrary initial order. [I have written down the initial ordering of the cards ahead of time.] I permute (shuffle) the deck according to a permutation vector (making sure not to let you see me do it, so you can't glean any information from the movements of my hands.) I give you the permuted deck of cards and ask you to return them to the original ordering I wrote down.
If I tell you that original ordering, the problem is easy.
If I tell you the permutation vector I used to shuffle the deck, the problem is easy.
If I tell you neither of those things, the problem is very difficult. There are about 8e67 ( factorial(52) ) different possible orderings of a standard deck of 52 cards. Good luck choosing the correct one at random.
So without some additional information, unshuffling the deck (inverting the permutation I applied) or unshuffling the rows in the matrix is going to be tough to do.
2 Kommentare
Siehe auch
Kategorien
Mehr zu Creating and Concatenating 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!