LTI DISCRETE-TIME SYSTEMS IN THE FREQUENCY DOMAIN
Illustration Filters
The length of the filter is N + 1.
The following program, which uses the function sinc, can be used to compute the above
approximation.
% Program
% Impulse Response of Truncated Ideal Lowpass Filter
clf;
fc = 0.25;
n = [-6.5:1:6.5];
y = 2*fc*sinc(2*fc*n);k = n+6.5;
stem(k,y);title(’N = 13’);axis([0 13 -0.2 0.6]);
xlabel(’Time index n’);ylabel(’Amplitude’); grid
Stability Test
% Program
% Stability Test
clf;
den = input(’Denominator coefficients = ’);
ki = poly2rc(den);
disp(’Stability test parameters are’);
disp(ki);
DIGITAL PROCESSING OF CONTINUOUS-TIME SIGNALS
% Program
% Illustration of the Sampling Process
% in the Time Domain
clf;
t = 0:0.0005:1;
f = 13;
xa = cos(2*pi*f*t);
subplot(2,1,1)
plot(t,xa);grid
xlabel(’Time, msec’);ylabel(’Amplitude’);
title(’Continuous-time signal x_{a}(t)’);
axis([0 1 -1.2 1.2])
subplot(2,1,2);
T = 0.1;
n = 0:T:1;
xs = cos(2*pi*f*n);
k = 0:length(n)-1;
stem(k,xs); grid
xlabel(’Time index n’);ylabel(’Amplitude’);
title(’Discrete-time signal x[n]’);
axis([0 (length(n)-1) -1.2 1.2])
Illustration Aliasing Effect in the Time Domain
% Program
% Illustration of Aliasing Effect in the Time Domain
% Program adapted from [Kra94] with permission from
% The Mathworks, Inc., Natick, MA.
clf;
T = 0.1;f = 13;
n = (0:T:1)’;
xs = cos(2*pi*f*n);
t = linspace(-0.5,1.5,500)’;
ya = sinc((1/T)*t(:,ones(size(n))) - (1/T)*n(:,ones(size(t)))’)*xs;
plot(n,xs,’o’,t,ya);grid;
xlabel(’Time, msec’);ylabel(’Amplitude’);
title(’Reconstructed continuous-time signal y_{a}(t)’);
axis([0 1 -1.2 1.2]);
Illustration Design of Analog Lowpass Filters
Program P5_3 can be used for the design of the Butterworth lowpass filter.
% Program P5_3
% Design of Analog Lowpass Filter
clf;
Fp = 3500;Fs = 4500;
Wp = 2*pi*Fp; Ws = 2*pi*Fs;
[N, Wn] = buttord(Wp, Ws, 0.5, 30,’s’);
[b,a] = butter(N, Wn, ’s’);
wa = 0:(3*Ws)/511:3*Ws;
h = freqs(b,a,wa);
plot(wa/(2*pi), 20*log10(abs(h)));grid
xlabel(’Frequency, Hz’);ylabel(’Gain, dB’);
title(’Gain response’);
axis([0 3*Fs -60 5]);
Illustration Binary Equivalent of a Decimal Number
Program used to the generate the binary equivalent in sign-magnitude form of
a decimal fraction.
% Program
% Determines the binary equivalent of a
% decimal number in sign-magnitude form
d = input(’Type in the decimal fraction = ’);
b = input(’Type in the desired wordlength = ’);
d1 = abs(d);
beq = [zeros(1,b)];
for k = 1:b
int = fix(2*d1);
beq(k) = int;
d1 = 2*d1 - int;
end
if sign(d) == -1;
bin = [1 beq];
else
bin = [0 beq];
end
disp(’The binary equivalent is’);
disp(bin)
Illustration Decimal Equivalent of a Binary Number
Program to perform the reverse process and generates the decimal equivalent of a binary
fraction in sign-magnitude form.
% Program
% Determines the decimal equivalent of a
% binary number in sign-magnitude form
bin = input(’Type in the binary fraction = ’);
b = length(bin) - 1; d = 0;
for k = 1:b
d = d + bin(k+1)*2^(-k);
end
if sign(bin(1)) == 0;
dec = d;
else
dec = - d;
end
disp(’The decimal equivalent is’);
disp(dec);
1 comments:
how to get time domain from frequency domain with ifft in matlab? with raw data in displacement and frequency.
Post a Comment