comparison userProgramsTim/fourier_analyse.m @ 38:c2204b18f4a2 tip

End nov big change
author Ray Meddis <rmeddis@essex.ac.uk>
date Mon, 28 Nov 2011 13:34:28 +0000
parents
children
comparison
equal deleted inserted replaced
37:771a643d5c29 38:c2204b18f4a2
1 function [frequency,out] = fourier_analyse(in, sfreq,color_plot)
2 %
3 %plots absolute values of fft of input signal on a semilogarithmic scale
4 %long term spectrum
5 %
6 %use: [frequency,out] = fourier_analyse(in, sfreq)
7 % in: input signal
8 % sfreq: samplingfrequency
9 % frequency: frequency vector
10 % out: fourier-spectrum (complex)
11 if ~exist('color_plot')
12 color_plot = 'b';
13 end
14 out = fft(in)/(length(in)); %%Normierung auf Wurzel der Länge, da Matlab intern ohne Normierung der Hin-Fouriertransformation arbeitet
15 t = [0:1/sfreq:length(in)/sfreq-1/sfreq];
16 frequency = [0:1/t(end):1/(2*(t(2)-t(1)))];
17 %spektrale leistungsdichte wird geplottet, wobei eine amplitude von 1 100
18 %dB entspricht
19 plot(frequency,20*log10(sqrt(2)*abs(out(1:round(length(in)/2)))),color_plot);
20 %sqrt(2) weil Gesamtenergie auch in Spiegelfrequenzen enthalten
21 xlabel('frequency / Hz');
22 ylabel('fourier amplitude / dB');