Relational Operator doesn't work

조회 수: 1 (최근 30일)
Esteban
Esteban 2013년 5월 23일
After a simulation I want to determine the limits of the axes using the relational operator ==. For example:
refTime = 0:2e-3:1.5;
t0 = 0.8;
find(refTime == t0)
this returns:
ans =
Empty matrix: 1-by-0
If I try the following in the same instance:
x = 0:10
find(x == 5)
It works and returns
ans = 6.
What could be wrong??

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 5월 23일
편집: Azzi Abdelmalek 2013년 5월 23일
Try
refTime = 0:2e-3:1.5;
t0 = 0.8;
tolerence=1e-5
find(abs(refTime-t0)<tolerence)
  댓글 수: 2
Esteban
Esteban 2013년 5월 23일
Thanks, this works :-) But I still don't see why my approach doesn't work. By visual inspection of refTime in the workspace I can see that it has an element with value exactly equal to t0.

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

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by