How to shift collum of matrix to the right ?

1 visualizzazione (ultimi 30 giorni)
Jenifer NG
Jenifer NG il 19 Ott 2022
Commentato: Jenifer NG il 19 Ott 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

Risposte (1)

VBBV
VBBV il 19 Ott 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 Commenti
Jenifer NG
Jenifer NG il 19 Ott 2022
Can we put in for loop to shift whole matrix ?
Jenifer NG
Jenifer NG il 19 Ott 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

Accedi per commentare.

Categorie

Scopri di più su Images in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by