How to shift collum of matrix to the right ?

1 visualización (últimos 30 días)
Jenifer NG
Jenifer NG el 19 de Oct. de 2022
Comentada: Jenifer NG el 19 de Oct. de 2022
Dear All,
I am trying to reshape my image by shifting the collum of matrix to the right.
Coud someone help me ?
[
I want to apply this method for my image as bellow
Thanks you so much!
Han

Respuestas (1)

VBBV
VBBV el 19 de Oct. de 2022
A = eye(10)
A = 10×10
1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1
A = circshift(A(3,:),1)
A = 1×10
0 0 0 1 0 0 0 0 0 0
You can use circshift function to shift position of zeros in the matrix as above
  3 comentarios
Jenifer NG
Jenifer NG el 19 de Oct. de 2022
Can we put in for loop to shift whole matrix ?
Jenifer NG
Jenifer NG el 19 de Oct. de 2022
a = [255 255 255 0 255
255 255 0 255 255
255 0 255 255 255
255 0 255 255 255
255 255 0 255 255
255 255 255 0 255
]
n = length(a)
for i = 1:n
if i<=3
b{i} = circshift(a(i,:),i)
else
b{i} = circshift(a(i,:),7-i)
end
end

Iniciar sesión para comentar.

Categorías

Más información sobre Images en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by