how to use 'bool' function?

조회 수: 13 (최근 30일)
sugata sinha
sugata sinha 2018년 2월 8일
편집: Stephen23 2019년 10월 2일
i am using matlab for seismic processing.plz help me with 'bool' function
  댓글 수: 1
Adam
Adam 2018년 2월 8일
There's no such thing as the 'bool' function in base Matlab

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

답변 (2개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 2월 8일
% A bool function means it returns to either true or false based on condition statement
if k==c % Condition statement
True statement;
else
False Statement
end
  댓글 수: 4
John Wheater
John Wheater 2019년 10월 2일
Sorry, I see we don't have a boolean data type, and we get a matrix of 1s or zeros.
So a function is useful, but should maybe contain just the one line
return (k==c)(1);
Stephen23
Stephen23 2019년 10월 2일
편집: Stephen23 2019년 10월 2일
"...we don't have a boolean data type, and we get a matrix of 1s or zeros."
Actually MATLAB has a logical type (displayed as 1s and 0s):
"So a function is useful..."
I don't see why. I would just write the logical comparison in my code.
"...but should maybe contain just the one line return (k==c)(1);"
That looks like a mixture of Python and MATLAB code (the keyword return does not return values in MATLAB, so that line performs some operations, discards any results, and then exits the function).

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


Walter Roberson
Walter Roberson 2018년 2월 8일
There is no bool in MATLAB or Simulink. There is boolean in Simulink, which is not recommended https://www.mathworks.com/matlabcentral/answers/375074-erro-using-boolean-with-matlab-on-window-machine#answer_298242
The only place that bool appears in Mathworks related code is in some of the interfaces for generated C++ code.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by