how do I flip ever column in a matrix without using the fliplr function?

18 visualizaciones (últimos 30 días)
n = randi([4,15]);
n_mat = randi ( [1,100], n, n)
this generates a matrix, and I want basically do the "fliplr" command with just operations

Respuesta aceptada

Voss
Voss el 18 de Mayo de 2022
n = randi([4,15]);
n_mat = randi ( [1,100], n, n)
n_mat = 6×6
8 27 54 5 24 28 86 65 85 87 30 81 21 47 87 93 29 33 18 84 9 44 42 68 40 67 83 92 87 95 63 2 87 95 68 35
n_mat_flipped = n_mat(:,end:-1:1)
n_mat_flipped = 6×6
28 24 5 54 27 8 81 30 87 85 65 86 33 29 93 87 47 21 68 42 44 9 84 18 95 87 92 83 67 40 35 68 95 87 2 63
  3 comentarios
Image Analyst
Image Analyst el 18 de Mayo de 2022
No. Colon : means "All rows" rather than an entire row. So it's reversing each and every row, putting the last column first, then the next to the last column, and finally on the right edge it will be the original first element in the row. Again that's done for all rows so all columns are flipped left to right..

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by