Get multiple indices coinciding closest to a certain value
Ältere Kommentare anzeigen
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)
Akzeptierte Antwort
Weitere Antworten (1)
the cyclist
am 4 Jul. 2013
0 Stimmen
You could use sort(val) rather than min(val), and you will get the sorted values, and the indices to them.
1 Kommentar
Samuel
am 4 Jul. 2013
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!