FFT Analysis of two signals

6 visualizaciones (últimos 30 días)
Christoph Bauer
Christoph Bauer el 14 de Mzo. de 2012
Hello everyone,
I have a beginners question about FFT analysis. I have two signals and I want to see the amplitudespectrum of them. I used the following code which was derived from the program desribed under mathworks.
Code:
Fs = 200; % Sampling frequency
T = 1/Fs; % Sample time
L = length (marker(1,2).C7); % Length of signal
t = (0:L-1)*T; % Time vector
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
y= marker(1,2).C7;
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
% Plot single-sided amplitude spectrum.
figure(1)
plot(f,2*abs(Y(1:NFFT/2+1)))
title('....')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
marker(1,2).C7 is the signal I want to analyse.
The following problem occured: If I run this program on two different signals I get the same amplitudespectrum for both although the signals are different. This cannnot be true as I wanted to compare the amplitudespectrum of the signal before and after it was filtered. Although they were filtered and they looked different when I ploted them the amplitudespectrum plotted with the above code showed no differences at all. Can anybody point out where I made a mistake?
Thank you for your help,
Christoph
  2 comentarios
Honglei Chen
Honglei Chen el 14 de Mzo. de 2012
It's not clear to me what you are comparing. Are you comparing two signals before filtering, or you are comparing one signal before and after filtering?
David Young
David Young el 14 de Mzo. de 2012
I think you may need to show the complete code that compares the two signals.

Iniciar sesión para comentar.

Respuesta aceptada

Wayne King
Wayne King el 15 de Mzo. de 2012
Let's assume that x is one signal and y is the other signal. If you have the Signal Processing Toolbox, you can quickly compare their power spectral densities with the following. fs below is your sampling frequency, so you need to put the correct value in for that.
psdestx = psd(spectrum.periodogram,x,'Fs',fs,'NFFT',length(x));
psdesty = psd(spectrum.periodogram,y,'Fs',fs,'NFFT',length(y));
plot(psdestx.Frequencies,10*log10(psdestx.Data));
title('PSD of x'); xlabel('Hz'); ylabel('dB/Hz');
figure;
plot(psdesty.Frequencies,10*log10(psdesty.Data));
title('PSD of y'); xlabel('Hz'); ylabel('dB/Hz');
  1 comentario
Christoph Bauer
Christoph Bauer el 15 de Mzo. de 2012
Thank you, that solved my problem

Iniciar sesión para comentar.

Más respuestas (1)

Christoph Bauer
Christoph Bauer el 15 de Mzo. de 2012
I want to compare the same signal before and after filtering.
There is no other code to compare the signals yet. The signal was measured and later filtered in another software, using a butterworth 4th order filter. After that I imported the signal into matlab, first the raw signal and then the filtered signal. Then I ploted both and used the above code to compare the signal before and after filtering.

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by