Author Topic: Finding peak values in Matlab  (Read 1999 times)

0 Members and 1 Guest are viewing this topic.

Offline KaramelTopic starter

  • Regular Contributor
  • *
  • Posts: 178
  • Country: tr
Finding peak values in Matlab
« on: October 23, 2016, 08:35:19 am »
Hi everyone,

Nowadays, I am working on sound recognation project via matlab. I am currently able to realize some notes. All of them are good but, I, now, have a problem with matlab.

I should recognize frequencies of peak values in my array. (fourier output) So, I can find peaks in my array like that,

Code: [Select]
pks = findpeaks(abs(F));
[m,n] = size(pks);
   
for i=1:m         
   fprintf('peak%i: %i\n',i, pks(i,1));
end
     
but it gives to me values of at max point. Not frequencies. (in frequency domain x axis describes frequencies and y axis describes magnetude of signal)

So, how can I get frequencies for all peak(local max values) values?

Best Regards,
Karamel
« Last Edit: October 23, 2016, 08:38:09 am by Karamel »
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11228
  • Country: us
    • Personal site
Re: Finding peak values in Matlab
« Reply #1 on: October 23, 2016, 05:22:31 pm »
Code: [Select]
[pks, locs] = findpeaks(data)

locs will contain locations of the peaks.
Alex
 

Offline KaramelTopic starter

  • Regular Contributor
  • *
  • Posts: 178
  • Country: tr
Re: Finding peak values in Matlab
« Reply #2 on: October 24, 2016, 02:29:07 pm »
Thanks for replying my question dear Atarov,

Actually, I had solved this problem when after asking but, I asked it and then, I went library, so I did not write solution.

Code: [Select]
[pks, locs] = findpeaks(abs(F))
[m,n] = size(pks);

In there, locs are local values, m and n are size of pks. If there is no signal. n = 1(n is always 1 because of pks is mx1 vector) and m = 0. If there is signal and is has some peak values, then, m has a different value that depends on peaks.

Matlab has a different coding and different approaching to solve problems. Okay, it looks like c programing but, certainly, it is different. I could, therefore, be asking stupid questions or etc. because of difference.

Thanks for all,
Karamel  ^-^
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf