I don't know why the compare with constant doesn't work. I have tried to use a relational operation block, but it is the same problem. I missing something? Please see the picture attached: image.png

 채택된 답변

Fangjun Jiang
Fangjun Jiang 2018년 6월 19일

1 개 추천

What is the data type of "lamba5"? I assume it is double or single. This is a typical "floating point equal or unequal comparison" issue. Convert the "lamba5" to integer or logical if it applies. Otherwise, you have to compare a floating point value with a threshold value, for example, if abs(lamba5-1)<=1e-6.

댓글 수: 3

Adriana Maria
Adriana Maria 2018년 6월 19일
Thanks. It works. I use this check to resolve divide by zero error. Do you have a suggestion for me for the comparison value, if 1e-6 is the better value. Or which is minimal value between 0 and 0.01, by which division works?
Fangjun Jiang
Fangjun Jiang 2018년 6월 19일
You have to decide the best threshold value based on your application. If it is divided by (lamba5-1), you have to decide by "how much" when lamba5 is close to the value of 1 that you want to do something differently.
Adriana Maria
Adriana Maria 2018년 6월 20일
Thank you very much!

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

추가 답변 (0개)

카테고리

질문:

2018년 6월 19일

댓글:

2018년 6월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by