0% found this document useful (0 votes)
119 views2 pages

Sigs 3

The document contains instructions for plotting the frequency responses of various discrete-time systems using MATLAB functions like freqz and fft. It also provides code to display images and their frequency spectra, along with filtering an image and plotting the results. The document contains code to read an audio file, plot the signal and its spectrogram. It describes taking the z-transform and dtft of a sequence and comparing the results to filtering to obtain the time domain sequence.

Uploaded by

api-26142417
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
119 views2 pages

Sigs 3

The document contains instructions for plotting the frequency responses of various discrete-time systems using MATLAB functions like freqz and fft. It also provides code to display images and their frequency spectra, along with filtering an image and plotting the results. The document contains code to read an audio file, plot the signal and its spectrogram. It describes taking the z-transform and dtft of a sequence and comparing the results to filtering to obtain the time domain sequence.

Uploaded by

api-26142417
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

function surname3

% 1.plot the frequency response of the following discrete-time systems.


%
% a. notch filter with 0db maximum gain, r = 0.75, w = pi/4 (figure 1)
% b. digital resonators with 0db maximum gain, r = .75, w = pi/4 (figure 2)
% c. comb filter with 0 db maximum gain, l =7, m =8 (figure 3)

r1=0.75;
w1=pi/4;
b1 = [1 -2*cos(w1) 1];
a1 = [1 -2*r1*cos(w1) r1^2];
figure(1)
freqz(b1,a1); title('notch filter');

b2 = [1 0 -1];
a2 = [1 -2*r1*cos(w1) r1^2];
figure(2)
freqz(b2,a2);title('digital resonator');

b3 = [1 zeros(0,61) -1];
a3 = [1 0 0 0 0 0 0 -1];
figure(3)
freqz(b3,a3);title('comb filter');

% 2.plot the frequency response of the discrete-time sequences using the matlab
function fft.
% use the following number of samples in the frequency domain, n = 16, 32, 64,
and 128.
% the magnitude should be expressed in decibels and the 4 magnitude responses
should be
% plotted in figure 4. use different colors for different values of n.

n = [0:15];
unit = [ones(1,16)] ;
xn= ((3/4).^n)*unit + (3/4)*cos(pi.*n/2)*unit;
n=[16 32 64 128];
[x,w]=freqz(b,a,512,'whole');

for m=1:length(n)
x=(1/2).^[0:511];
x1=fft(x,n(m));
k=0:n(m)-1;
w1=k*2*pi/n(m);
plot(w1,20*log10(abs(x1)),c(m));
hold on;
end

% 3.display the following in figure 4: a.) the frequency spectrum of the image
mapped_gray.jpg,
% b.) the image mapped_gray.jpg, c.) the filtered image, d.) spectrum of the
filtered image,
% e.) the spectrum of the twodimensional filter, and f.) the spectrum of the
two-dimensional
% filter in 3d. the center of the spectrum must be at the center and the
resolution of the
% spectrum must be 512 x 512. use the following filter coefficients:
h=[-1 -1 -1;-1 8 -1;-1 -1 -1]
i=imread('mapped_gray.jpg','jpg');
ifil=conv2(h,i);
i=fft2(i,512,512);
iabs=abs(i);
ilog=20*log10(1+iabs);

figure(5)
% subplot(321);freqz(i);title('frequency spectrum');
subplot(322);image(i);colormap(gray(256));title('original');
subplot(323);image(ifil);colormap(gray(256));title('filtered');

% 4.plot the audio signal mydtmf.wav and its corresponding spectrogram in figure
5.
% the number of samples per frame should be 256 with 128 overlaps.

[x4,fs,nbits] = wavread('mydtmf.wav');
t4=0:1/fs:(length(x4)-1)/fs;
figure(6)
subplot(211);plot(t4,x4);
subplot(212);specgram(x4,256,fs,hamming(256),128);

% 5.the z-transform of a causal sequence is give by the expression given below.


% write the corresponding expression in matlab equivalent to the dtft of the
causal sequence
% by substituting . sample the continuous-frequency for one period (0 to 2?) to
arrive at
% the following number of samples in the time domain: n = 8, 16, and 32. use ifft
to get
% the time-domain sequence and compare the resulting time domain sequence from the
sequence
% obtained using the matlab function filter. plot the errors for different n in
figure 6.
% the errors for each n should display the first 8 sample sequence only.

b5=[0.0947 0.2481 0.2481 0.0947];


a5=[1 -0.7130 0.6287 -0.1581];

You might also like