Reputation: 37
I have 2 FFT spectrums on a plot. I want to get the top 5 maximum points of the overall plot. I get the maximum points separately for each spectrum. How can i combine these spectrums into one and get the overall maximum 5 points?
Upvotes: 0
Views: 95
Reputation: 4648
Put the spectra in one vector and sort them in descending order.
spec1 = fft(x1); % a spectrum (column vector)
spec2 = fft(x2); % another spectrum (column vector)
dummy = abs([spec1; spec2]); % concatenate absolute values
sorted = sort(dummy, 'descending');
five_greatest = sorted(1:5);
Upvotes: 0
Reputation:
You have two separate maximum matrix: lets Max1
and Max2
Now combine both of them to form third matrix
Max3 = [Matx1 Max2]
Sort the Max3 in descending order
Max3 = sort(Max3,'descend');
Extract the first 5 element
peaks = Max3(1:5)
Upvotes: 1