Professional Documents
Culture Documents
(a) Delta function: δ (n) .: 1. Plot the following functions using MATLAB
(a) Delta function: δ (n) .: 1. Plot the following functions using MATLAB
n = -5:5;
x = zeros(size(n));
x(n==0) = 1;
stem(n,x);
axis([-5.5 5.5 -0.2 1.2]);
grid on;
t = -5:0.05:5;
y = zeros(size(t));
y(t>=0) = 1;
subplot(121);
plot(t,y);
axis([-5 5 -0.2 1.2]);
grid on;
% DT
n = -5:5;
x = ones(size(n));
x(n<0) = 0;
subplot(122);
stem(n,x);
axis([-5.5 5.5 -0.2 1.2]);
grid on;
subplot(211);
plot(t,y);
axis([-5 5 -0.2 5.5]);
grid on;
%DT
x = x.*n;
subplot(212);
stem(n,x);
axis([-5 5 -0.2 5.5]);
grid on;
subplot(211);
plot(t,y);
axis([-5 5 -0.2 1.2]);
grid on;
title('Rectangle Pa(t)');
xlabel('t');
ylabel('Pa(t)');
% DT
n = -5:5;
x = zeros(size(n));
x(n>=-2 & n<=3) = 1;
subplot(212);
stem(n,x);
axis([-5 5 -0.2 1.2]);
grid on;
title('Rectangle Pa[n]');
xlabel('n');
ylabel('Pa[n]');
2. Write a MATLAB program to generate and plot the signals x1(t)=2cos(t 3 ),
x2(t)=3cos(2t 9 ),and x3(t)= x1(t)+ x2(t). Observe the nature of each signal
and identify their fundamental periods.
t=-10:0.1:10;
x1=2*cos(pi*t/3);
x2=3*cos(2*pi*t/9);
x3=x1+x2;
subplot(3,1,1);
plot(t,x1);
axis([-10 10 -5.2 5.2]);
subplot(3,1,2);
plot(t,x2);
axis([-10 10 -5.2 5.2]);
subplot(3,1,3);
plot(t,x3);
axis([-10 10 -5.2 5.2]);
3. Write a MATLAB program to generate and plot the signals x1[n]=5cos(0.5n)and x2[n]=5cos(2 12 n).
Comment on the nature and periodicity of the signals. Identify the fundamental period of the signals, if
exists.
n=-10:1:10;
x1=5*cos(0.5*n);
x2=5*cos(2*pi*n/12);
subplot(2,1,1);
stem(n,x1);
axis([-10 10 -6.2 6.2]);
subplot(2,1,2);
stem(n,x2);
axis([-10 10 -6.2 6.2]);
4. The Continuous Time (CT) exponential signal is given as x(t)= Cet. Consider the case when C and
are both complex, where C is expressed in polar form i.e., (C =|C|ej)and a in rectangular form i.e.,(a = r
+ jo). Then your function x(t), on simplication, becomes x(t)=|C|ert[cos(ot +)+ jsin(ot +)]. Taking
o =0.1and =0; plot the real and imaginary parts signal for different values ofrand comment on the
results for i) r =0(this case is same as 4. (b) for =0), ii) r <0(take r =0.01,0.1), and iii) r >0(take r
=0.01,0.1). What happens when we take = 4 instead.
C = 1.5;
w = 0.1;
theta = 0;
t = -200:0.1:200;
r = 0;
y = C*exp(r*t).*(cos(w*t + theta) +
j*sin(w*t + theta));
subplot(321);
plot(t,real(y));
grid on;
(b) Consider the case when C and are both complex, where C =|C|
ej and =||ejo. Then x[n]becomes x[n]=|C|||nej(on+).
Taking C =1.5, =0and o = 6 , observe and comment on results
for different cases of : i)||=1 ii)||>1=> (||=1.5) iii)||
<1=> (||=1.5).
C = 1.5;
w = pi/6;
theta = 0;
a = 1;
y = abs(C)*(abs(a).^n).*exp(1j*w*n+theta);
figure(2);
subplot(321);
stem(n,real(y));
grid on;
subplot(322);
stem(n,imag(y));
grid on;
a = 1.05;
y = abs(C)*(abs(a).^n).*exp(1j*w*n+theta);
figure(2);
subplot(323);
stem(n,real(y));
grid on;
subplot(324);
stem(n,imag(y));
grid on;
a = 0.95;
y =
abs(C)*(abs(a).^n).*exp(1j*w*n+theta);
figure(2);
subplot(325);
stem(n,real(y));
grid on;
subplot(326);
stem(n,imag(y));
grid on;