Get multiple indices coinciding closest to a certain value
古いコメントを表示
Hello all,
I have an x by 2 array- it is a freq vs amplitude graph. The graph is similar in shape to a typical ideal frequency curve (going uphill to a peak point then downhill).
I am trying to write a code that will detect the half power of the amplitude, and display the frequency of the two half power locations(since it goes up and down).
With some research(stackoverflow forums), I was able to devise a code utilizing the minimum difference between the value and half power value, but this code approach only can get me the first half power point- any help in getting the second one as well will be of great help. Thanks!
the code portion is below:
%halfpow is the number I want to be searched for
%v1 is the column vector that contains the amplitudes
val=abs(v1-halfpow);
[ind ind]=min(val);
closest=v1(ind)
採用された回答
その他の回答 (1 件)
the cyclist
2013 年 7 月 4 日
0 投票
You could use sort(val) rather than min(val), and you will get the sorted values, and the indices to them.
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!