for if matrix
조회 수: 2 (최근 30일)
이전 댓글 표시
for i=1:n-1
for j=1:n-1
for r=1:332
if i + r > 333
data(i+r,:)=0;
*else if i-r = < 0
data(i-r,:)=0;*
else if j+r > 333
data(:,j+r)=0;
else if j-r = < 0
data(:,j-r)=0;
end
end
end
end
end
end
end
Please tell me how I can correct the error at i-r = < 0
채택된 답변
Walter Roberson
2012년 2월 4일
Change the '= <' to '<=' (without the apostrophes.)
댓글 수: 9
Walter Roberson
2012년 2월 4일
Your line s=s+data(i+r,j)+data(i-r,j) is outside of any of your "if" tests, so it is going to always be executed. It will cause a problem if i-r is 0 or negative.
추가 답변 (1개)
Jan
2012년 2월 4일
Do you really have a space between the = and the < ? If so, remove it.
Please add the error message. Otherwise we have to guess, what your problem might be.
참고 항목
카테고리
Help Center 및 File Exchange에서 Whos에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!