Implement the body of the function rotationMatrix(),

조회 수: 3 (최근 30일)
Ian
Ian 2022년 11월 2일
답변: Image Analyst 2022년 11월 3일
function M = rotationMatrix( Size, Shift )
% Generate a square permutation matrix if size Size.
% The permutation is a right rotation - the ROR operation.
% That is the right-multiplication of a row-vector by this matrix performs
% a cyclic shift of vectors positions - the ROR operation.
% The scalar shift specifies how many positions to rotate
% if negative, a ROL operation is performed.
% You cannot use any toolbox functions of cycles,
% just indexing of an identity matrix.
HOW DO THIS? I CANT FIND SOMFTHING FOR THIS
  댓글 수: 9
Jan
Jan 2022년 11월 2일
@Steven Lord: Thanks.
@Ian: Please note that many members of this forum do not speak English natively. Then smart abbreviations are not cool, but confusing.
Ian
Ian 2022년 11월 2일
@Jan Okey

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

답변 (1개)

Image Analyst
Image Analyst 2022년 11월 3일
Hint:
v = 1:15
v = 1×15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
shift = 3;
vShifted = [v(end-shift+1 : end), v(1:end-shift)]
vShifted = 1×15
13 14 15 1 2 3 4 5 6 7 8 9 10 11 12
shift = -3;
vShifted = [v(-shift+1 : end), v(1:-shift)]
vShifted = 1×15
4 5 6 7 8 9 10 11 12 13 14 15 1 2 3

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by