0% found this document useful (0 votes)
5 views7 pages

MATLAB Signals and Spectrum Analysis

The MATLAB assignment involves generating and analyzing an analog input signal x(t) and its corresponding digital signal x[n]. The assignment includes convolution to obtain the digital output signal y[n], reconstructing the analog output signal y(t), and analyzing the frequency domain of both signals. The results indicate that while the signals are similar, the 20 Hz frequency component is absent in the output.

Uploaded by

b00087741
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views7 pages

MATLAB Signals and Spectrum Analysis

The MATLAB assignment involves generating and analyzing an analog input signal x(t) and its corresponding digital signal x[n]. The assignment includes convolution to obtain the digital output signal y[n], reconstructing the analog output signal y(t), and analyzing the frequency domain of both signals. The results indicate that while the signals are similar, the 20 Hz frequency component is absent in the output.

Uploaded by

b00087741
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ELE 323

Dr. Hasan Mir

MATLAB ASSIGNMENT 1

Name: Mohamed Hesham Eid


ID: b00089309
1. Analog Input Signal x(t):

fs = 10;
Ts = 1/fs

Ts =

0.1000

T = 0:10^-2:10;
X_T = 1 + cos(2*pi*T) + cos(4*pi*T) +cos(8*pi*T);
figure (1);
plot (T, X_T);
title ("Analog Input Signal x(t)");
xlabel("Time (sec)");
ylabel ("Amplitude");

Comments:
First, I set the sampling frequency to 10 Hz. The sampling frequency is 1/fs, which
equals 0.1 seconds as shown in the code above. I set a timer to achieve over 100 samples with
a time step of 10^-2 seconds. I defined the analog signal as X_T, opened a figure window,
requested a plot, and labelled the graph title and axes. The graph generated in figure one is
shown below.

Figure 1 Analog Input Signal x(t)


2. Digital Input Signal x[n]:

X_N = X_T(1:10:end);
N = 0:length(X_N)-1;
figure (2);
stem (N,X_N,'filled');
title("Digital Input Signal x[n]");
xlabel("Sample Index");
ylabel("Amplitude");

Comments:
X_N stores the values every 0.1 seconds following the sampling period. We need to
save or store 100 samples into X_N. Furthermore, like the previous figure, I labelled the titles
and axes as shown. The stem command is used for digital signals, whereas the plot command
is used for analog signals. The graph generated in figure two is shown below.

Figure 2 Digital Input Signal x[n]

3. Impulse Response h[n] and Digital Output Signal y[n]:

H_N = [1,-2*cos(0.4*pi),1];
Y_N = conv(H_N, X_N);
figure (3);
N = 0:length(Y_N)-1;
stem(N,Y_N,'filled');
title("Digital Output Signal y[n]");
xlabel("Sample Index");
ylabel("Amplitude");

Comments:
I defined the impulse response as H_N and requested the convolution to achieve the
output in Y_N. The graph generated in figure three is shown below.

Figure 3 Digital Output Signal y[n]

4. Analog Output Signal y(t) [Reconstructed Signal]:

T = 0:10^-2:10;
Y_T = 0;
for n=0:101
Y_T = Y_T + Y_N(n+1)*sinc(fs*(T-n*Ts));
end
figure(4);
plot(T,Y_T);
title("Analog Ouput Signal y(t)");
xlabel("Time (sec)");
ylabel("Amplitude");
Comments:
I used a for-loop to generate the reconstructed analog output. The graph generated in
figure four is shown below.

Figure 4 Analog Output Signal y(t)

5. Spectrum of x(t) and y(t):

T = 0:10^-2:10;
figure(5);
X_SPEC = fft(X_T);
plot (abs(X_SPEC));
title ("Frequency Domain of x(t)");
xlabel ("Frequency (HZ)");
ylabel("Amplitude");
xlim([0 65]);
figure(6);
Y_SPEC = fft(Y_T);
plot(abs(Y_SPEC));
title("Frequency Domain of y(t)");
xlabel("Frequency (Hz)");
ylabel("Amplitude");
xlim([0 65]);
Comments:
I plotted the absolute values of X as well as Y and used the xlim command to show 60
Hz as the maximum value on the x-axis. The two graphs generated in figures five and six
respectively are shown below.

Figure 5 Frequency Domain of x(t)

Figure 6 Frequency Domain of y(t)


6. Discussion of Results:

The results obtained from this experiment were reasonable. The first thing to notice when
comparing x(t) and y(t) in figures five and six is how the 20 Hz frequency was not visible
anymore. Other than that, both signals look very similar.

You might also like