필터 지우기
필터 지우기

Why are the inequality expressions not evaluated correctly?

조회 수: 2 (최근 30일)
ingstalam
ingstalam 2015년 2월 2일
답변: Image Analyst 2015년 2월 2일
My code is: grid is just a 5x6 matrix, so is visited.
neighbor=[3 4]
if((neighbor(1)>0) && (neighbor(1)<size(grid,1)+1) && (neighbor(2)>0) && (neighbor(2)<size(grid,2)+1) && (visited(neighbor(1),neighbor(2)==-1)))
Matlab gives the following error: Operands to the and && operators must be convertible to logical scalar values.
What's going wrong? I tried to debug step by step but could not figure out the mistake.

채택된 답변

Image Analyst
Image Analyst 2015년 2월 2일
Perhaps you meant:
if((neighbor(1)>0) && (neighbor(1)<size(grid,1)+1) && (neighbor(2)>0) && (neighbor(2)<size(grid,2)+1) && (visited(neighbor(1),neighbor(2))==-1))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by