필터 지우기
필터 지우기

martix with mod question

조회 수: 2 (최근 30일)
ahmad
ahmad 2012년 7월 4일
i have the following code
for i=1:n1*n2
for j=1:n1*n2
gi=mod(i,n2)
if(~gi)
gi=n2;
end
gj=mod(j,n1)
if(~gj)
gj=n1;
end
where n1= 8 and n2 = 6 what exactly each line means ????
thanks
  댓글 수: 1
Luffy
Luffy 2012년 7월 4일
편집: Walter Roberson 2012년 7월 4일
Your code doesn't work,for loops don't end,what are gi & gj,

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

답변 (1개)

Luffy
Luffy 2012년 7월 4일
편집: Luffy 2012년 7월 4일
Explained,
for i = 1:n1*n2 % for loop with i increasing from 1 to n1*n2(48 in your case)
for j = 1:n1*n2 % for loop with j increasing from 1 to n1*n2
gi = mod(i,n2); % modulo operator(example:if i is 4,mod(4,6)=4=g4)
if(~gi) % for all those gi which are not zero they are equal to n2
gi = n2;
end
gj = mod(j,n1); % similar to i
if(~g2)
gj = n1;
end
end
end

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by