Increasing value over time of Power of a audio signal
32 次查看(过去 30 天)
显示 更早的评论
Hi everyone, i have an audio signal and the power of the same signal increases over time (with more samples) so i have a very big value of the power and a wrong power spectrum if i use this code
% Lunghezza del segnale e trasformata FFT
m = length(xn); % lunghezza del segnale originale
y = fft(xn, m); % calcolo della FFT del segnale
% Vettore delle frequenze
f = (0:m-1) * (fs / m); % frequenze associate ai campioni FFT
% Calcolo dello spettro di potenza normalizzato
power = abs(y).^2 / m; % spettro di potenza normalizzato
% Plot dello spettro di potenza
figure;
plot(f(1:floor(m/2)), power(1:floor(m/2))); % plottiamo solo la metà positiva
xlabel('Frequency (Hz)');
ylabel('Power');
title('Power Spectrum of Signal');
But if i use the function pspectrum or the signal analyzer app i have different results much smaller
[p, f] = pspectrum(xn, fsn, 'power'); % Calcola la potenza spettrale e la frequenza
plot(f, p); % Plotta la potenza spettrale in funzione della frequenza
xlabel('Frequency (Hz)');
ylabel('Power/Frequency (dB/Hz)');
title('Power Spectrum of Signal');
same plot for pspectrum and signal analyzer so i think it s correct, why i have that error with power over 160 db/hz? i need to calculate the power myself cause i need the values for a model thank you
0 个评论
采纳的回答
William Rose
2024-11-14,17:22
You say "I need to calculate the power myself cause i need the values for a model".
The first plot you provided has the vertical axis label cut off, so I am not sure how it differs from the second plot. Normalization of the power spectrum depends on several choices, including whether you want the power spectrum or the power spectral density, one-sided versus two-sided, winodw choice and possible adjustment for windowing, etc. See here for a discussion of these choices, and how to get results from fft() that match the results from other matlab approaches to estimating the spectrum. The second plot you show uses pspectrum() to compute the spectrum. pspectrum() makes a lot of decisions based on the length of the time-domain sequence, etc. See here for details. It will be a lot of work to write your own code that gives the same output as pspectrum.
If you want to compute the power yourself, then do it by a consistent and clear method, the same way every time. The values you obtain will work with the model you develop.
5 个评论
William Rose
2024-11-16,7:12
If you want signal power for classificaiton purposes, why not just compute the variance of the time domain signal?
I suspect that if you are consistent in your use of pspectrum() with various signals, then the outpout from pspectrum() will work just as well for classificaiton as if you used abs(fft()/N).^2 or cpsd() or some other approach.
pspectrum() uses as many samples as you pass to it. It appears, from the spectra produced by pspectrum(x,fs,'power'), that it pads with zeros. I agree that it is not obvious from the documentation.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!