what is the median frequency matlab code?
이전 댓글 표시
hello everybody,, my question what is the median frequency(MF) mat-lab code ,if the median frequency defined as the frequency that divides the magnitude-spectrum in two parts of equal size(the area under the curve for lower frequencies than MF equals the area under the curve for the frequencies higher than MF. first of all i've got the plot of the magnitude spectrum then i used trapz(x,y) to get the whole area under the curve, now i need a code to know what is the frequency that divides the total area into 2 equal parts ?!
댓글 수: 12
haya alawneh
2016년 3월 3일
Star Strider
2016년 3월 3일
Your unformatted code makes absolutely no sense to me.
I gave you code that will calculate the median frequency, as you requested.
haya alawneh
2016년 3월 3일
Star Strider
2016년 3월 3일
My pleasure.
If my Answer solved your problem, please Accept it.
What is your question?
haya alawneh
2016년 3월 3일
Star Strider
2016년 3월 3일
For relative power, use the find function to find the indices corresponding to your frequencies of interest, then use trapz to integrate the 100-500 range and the total power.
To calculate the power spectral density, see the documentation on Power Spectral Density Estimates Using FFT.
I do not know what you mean by ’zero crossing’. There should be no zero-crossing in the power spectral density.
haya alawneh
2016년 3월 3일
Star Strider
2016년 3월 3일
I am still not certain what you are doing the zero-crossings on. You can use this little function to get their approximate indices:
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Zero-Crossing Indices Of Argument Vector
Use trapz. (The cumtrapz function is also an option.)
haya alawneh
2016년 3월 3일
Star Strider
2016년 3월 3일
My pleasure.
I don’t mind answering questions in my areas of expertise!
haya alawneh
2016년 3월 3일
Star Strider
2016년 3월 3일
In the code in my Answer, the time vector (actually, deriving the sampling interval from it) is used to calculate the sampling frequency, and from the sampling frequency, the frequency vector.
The sampling interval, ‘Ts’ is defined in my code as:
Ts = mean(diff(t));
and the sampling frequency as:
Fs = 1/Ts;
I combined them in one statement in the code in my Answer.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Spectral Measurements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
