Digital Signal Processing Reference
In-Depth Information
Anmerkung: Der überwiegende Teil des Programms besteht aus Befehlen zur grafischen Darstellungen
und Textausgabe am Bildschirm.
dsplab5_1 : distortion
f0 = 50 Hz
fs = 1000 Hz
max|X(f)| = 0.315688
f in Hz |X(f)|/max|X(f)|
0 1.0000
50 0.7919
100 0.3446
150 0.0000
200 0.0762
250 0.0000
300 0.0388
350 0.0000
400 0.0278
450 0.0000
distortion d = 0.4101
1
0.5
0
0
5
10
15
20
t in ms o
1
0.5
0
0
50
100
150
200
250
300
350
400
450
f in Hz o
Bild 5-8 Gleichgerichtetes Sinussignal (eine Periode) und normiertes DFT-Betragsspektrum (links) und
Textanzeige (rechts) zu Programmbeispiel 5-1 Klirrfaktor-Messung ( dsplab5_1 )
Programmbeispiel 5-1 Klirrfaktormessung mit der DFT
% Short-time spectral analysis with the fft
% dsplab5_1.m * mw * 04/03/2008
f0 = 50; T0 = 1/f0; % fundamental frequency in Hz and signal period
fs = 1e3; Ts = 1/fs; % sampling frequency and sampling period
Ns = floor(T0/Ts);
% number of samples per period
n = 0:Ns-1;
% normalized discrete time
x = zeros(1,Ns);
for k=1:Ns
t = Ts*n(k);
if t<T0/2
x(k) = sin(2*pi*f0*t);
% sinus half wave
end
end
X = fft(x);
% dft spectrum
X = X/Ns;
% normalize dft spectrum
% Graphics
% Time signal, sampled signal
t = 1e3*Ts*n; % time scale in ms
FIG1 = figure('Name','dsplab5_1 : distortion','NumberTitle','off');
subplot(2,1,1),
plot(t,x,t,x,'.','MarkerFaceColor','b','MarkerEdgeColor','b','MarkerSi
ze',20), grid
axis([0 1e3*Ts*Ns 0 1]);
xlabel('{\itt} in ms \rightarrow'), ylabel('{\itx}({\itt})
\rightarrow')
% DFT spectrum
M = Ns/2;
% omit spectral line at normalized frequency pi
if rem(Ns,2)==0
M = Ns/2 - 1;
end
Search WWH ::




Custom Search