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!