필터 지우기
필터 지우기

What does || mean?

조회 수: 33 (최근 30일)
hde
hde 2012년 3월 19일
I am trying to understand the following line of code, but have found it difficult to do a search of '||' . The line of code is:
if (x<1 '||' x>size(points.data,1))
(please note the '||' part in the line of code does not actually have quotation marks, i cannot type in '||' without using the quotation marks otherwise the lines do not show up!)
Does it mean, if x is less than 1, and also if x is greater than the size of the data 'points' in column 1 ?
  댓글 수: 1
Image Analyst
Image Analyst 2012년 3월 19일
Probably because you didn't format it as "code" like I did below, where it showed up fine.

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

답변 (1개)

Image Analyst
Image Analyst 2012년 3월 19일
It means "or" - not sure why it didn't show up in the code you posted. Your code probably should say
if (x<1 || x>size(points.data,1))
% x is outside the acceptable range.
else
% x is inside the acceptable range.
end
  댓글 수: 1
Kevin Holst
Kevin Holst 2012년 3월 19일
also, it's the short circuit operator. It evaluates the second operand only if it needs to.

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

카테고리

Help CenterFile Exchange에서 Time Series Events에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by