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 Center および File ExchangeImages についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by