How to shift collum of matrix to the right ?

1 Ansicht (letzte 30 Tage)
Jenifer NG
Jenifer NG am 19 Okt. 2022
Kommentiert: Jenifer NG am 19 Okt. 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

Antworten (1)

VBBV
VBBV am 19 Okt. 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 Kommentare
Jenifer NG
Jenifer NG am 19 Okt. 2022
Can we put in for loop to shift whole matrix ?
Jenifer NG
Jenifer NG am 19 Okt. 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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by