フィルターのクリア

Problem with a statement in code.

1 回表示 (過去 30 日間)
Nancy
Nancy 2011 年 9 月 30 日
Hi Guys,
This should be working fine but it just isnt. Please help me. I have been using the code from this question http://www.mathworks.com/matlabcentral/answers/11204-getting-data-values-from-a-plot
I am facing problems with one statement "yfound = yi(abs(xi-findyatx)<eps);"
If the array xi has the same element as that of findyatx, that location will have an value of 1 while all others will have zero. I can see that there is an element in xi that has the same value as that of findyatx. But still all I get as a answer for yfound is an empty matrix.
Someone please help.

採用された回答

Walter Roberson
Walter Roberson 2011 年 9 月 30 日
It is not a good idea to use eps as the tolerance, as eps by itself is eps(1) which is less than the distance between adjacent numbers by the time you get to even just 2. You should use max(eps(xi),eps(findyatx)) at the very least, and multiples of that are usually better.
  2 件のコメント
Nancy
Nancy 2011 年 9 月 30 日
Thanks Walter. How would you use max(eps(xi),eps(findyatx)) in that code.? I used 0.00001 instead of eps and the code seemed to work fine.
Thanks once again.
Walter Roberson
Walter Roberson 2011 年 9 月 30 日
tolerance = 10 * max(eps(xi),eps(findyatx));
yfound = yi(abs(xi-findyatx)<tolerance)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by