How to shift collum of matrix to the right ?

조회 수: 1 (최근 30일)
Jenifer NG
Jenifer NG 2022년 10월 19일
댓글: Jenifer NG 2022년 10월 19일
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

답변 (1개)

VBBV
VBBV 2022년 10월 19일
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
Jenifer NG
Jenifer NG 2022년 10월 19일
Can we put in for loop to shift whole matrix ?
Jenifer NG
Jenifer NG 2022년 10월 19일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by