How to shift a matrix
Ältere Kommentare anzeigen
Say I have a matrix that is 3x3:
1 2 3
4 5 6
7 8 9
I want to shift the top and bottom rows:
1 2 3
4 5 6
7 8 9
This would expand it into a 3x4 matrix yes but i mostly want to know how specifically to do this shifting. I was told the imwarp function could help but im not sure. I'm thinking I would have to define a matrix for the first one to shift to? Or something like that?
4 Kommentare
the cyclist
am 11 Okt. 2019
Do you mean a numeric array, or a cell array?
If a numeric array, what do you want in the "empty" spaces (which cannot be empty in a numeric array). Zero? NaN?
Aldo Hernandez
am 11 Okt. 2019
Adam
am 11 Okt. 2019
They way you have drawn your shifting suggests more than a 3x4 output as your shifted numbers fall in the gaps between the row below/above, which would require a larger matrix to include. Or are the 1, 5 and 7 supposed to all line up in the 2nd column?
Aldo Hernandez
am 11 Okt. 2019
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!