0% found this document useful (0 votes)
66 views8 pages

Exercise of S&S Lab # 03

The document contains the code to plot various continuous and discrete time signals including: 1) Exponential signals with equations X(t)=5e^-6t, Y(t)=3e^3t, X[n]=2(0.85)^n, and X[n]=2(exp)^2n. 2) Sinusoidal signals with equations for a cosine signal of 10 Hz and sine signal of 100 Hz. 3) Impulse and step signals including a discrete impulse and continuous step function. 4) A ramp signal with equation x(t)=t and a sinc function plot. 5) A rectangular pulse function of width 3 units and signal x(t)=t

Uploaded by

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

Exercise of S&S Lab # 03

The document contains the code to plot various continuous and discrete time signals including: 1) Exponential signals with equations X(t)=5e^-6t, Y(t)=3e^3t, X[n]=2(0.85)^n, and X[n]=2(exp)^2n. 2) Sinusoidal signals with equations for a cosine signal of 10 Hz and sine signal of 100 Hz. 3) Impulse and step signals including a discrete impulse and continuous step function. 4) A ramp signal with equation x(t)=t and a sinc function plot. 5) A rectangular pulse function of width 3 units and signal x(t)=t

Uploaded by

fghfg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

IJAZ UL HAQ CMS ID: 33210

Exercise of Lab # 03
Draw the following signals:

Q1) Exponential
(a) X(t)=5e^-6t

T=0:01:1;
A=00.1;
B=-6;
x=A*exp(B*T);
plot (T,x)
grid on
title(' Continuous time exponential signal)
xlabel('T')
ylabel('A')
legend('Exponential signal')

(b) Y (t)=3e^3t

T=0:01:1;
A=3;
B=-3;
x=A*exp(B*T);
plot (T,x)
grid on
title(' Continuous time exponential signal)
xlabel('T')
ylabel('A')
legend('Exponential signal')
IJAZ UL HAQ CMS ID: 33210

(c) X[n]=2(0.85)n

N=0:0.01:1;
A=2;
x=A*(0.85)*N;
stem (N,x)
grid on
title(' Discrete time exponential signal')
xlabel('N')
ylabel('A')
legend(' Discrete Exponential signal')

(d) X[n]=2(exp)^2n

N=0:0.01:1;
A=2;
B=2;
x=A*exp(B*N);
stem (N,x)
grid on
title(' Discrete time exponential signal')
xlabel('N')
ylabel('A')
legend(' Discrete Exponential signal')
IJAZ UL HAQ CMS ID: 33210

Q2) Sinusoidal

(a) Cos of frequency 10 Hz

time=0:0.001:1;
amplitude=8;
frequency=10;
w=2*pi*frequency;
x=amplitude*cos(w*time);
plot(time,x)
grid on
title('Cos Signal')

(b) Sine of frequency 100 Hz

time=0:0.001:0.1;
amplitude=20;
frequency=100;
w=2*pi*frequency;
x=amplitude*sin(w*time);
plot(time,x)
grid on
title(' Sine signal')
IJAZ UL HAQ CMS ID: 33210

Q3) Impulse

(a) Discrete time impulse function

N=10:1:10;
x=[zeros(1,10),1,zeros(1,10)];
stem (N,x);
grid on
title(' Unit Impulse Signal')
xlabel('N')
ylabel('x')

(b) Continuous time impulse function

N=(-1:001:1);
impulse=T==0;
stem (T,impulse);
grid on
title(' Continuous Time Impulse Signal')
xlabel('T')
ylabel('A')
IJAZ UL HAQ CMS ID: 33210

Q4) Step

(a) x[n]=4 (step function)

N=4; % no of sample
N=-N:1:N;
N= [-4 -3 -2 -1 0 1 2 3 4]
x= [zeros(1,N) 1 ones(1,N)]
x= [0 0 0 0 1 1 1 1 1]
stem(n,x);
grid on
xlabel ('Time');
ylabel('Amplitude');
title('Unit Step');

(b) x (t)=4 (step function)

T=4; % no of sample
t=-T:1:T;
T= [-4 -3 -2 -1 0 1 2 3 4]
x= [zeros(1,T) 1 ones(1,T)]
x= [0 0 0 0 1 1 1 1 1]
stem(t,x);
grid on
xlabel ('Time');
ylabel('Amplitude');
title('Unit Step');
IJAZ UL HAQ CMS ID: 33210

Q5) Ramp

(a) x(t)=t (Ramp Function)

n=input('Enter the length of ramp sequence N=');% get the length


s=input('Enter the slop of the ramp S=');% get the slop of the ramp
t=0:n-1;
plot(t,s*t);
grid on
title('Ramp signal');
ylabel('Amplitude');
xlabel('Time')
Enter the length of ramp sequence N=6
Enter the slop of the ramp S=6

(b) x(t)=t (Ramp Function)

n=input('Enter the length of ramp sequence N=');% get the length


s=input('Enter the slop of the ramp S=');% get the slop of the ramp
N=0:n-1;
stem(N,s*N);
grid on
title('Ramp signal');
ylabel('Amplitude');
xlabel('Time Index')
Enter the length of ramp sequence N=6
Enter the slop of the ramp S=6
IJAZ UL HAQ CMS ID: 33210

Q6) Sinc

(a) Get helpfor for built in function “sinc” and hence plot sinc function
(sin(x)\x) for x between -5 to 5.

x=linspace(-5,5);
y=sinc(x);
plot(x,y)
grid on
title('Sinc Function')
xlabel('x')
ylabel('y')

Q7) Plot the following

(a) Rectangular pulse function width 3 units.

t=0:0.001:2;
w=3;
x=rectpuls(t,w);
plot(t,x)
plot(t,w)
grid on
title('rectangular pulse function')
xlabel('t')
ylabel('A')
IJAZ UL HAQ CMS ID: 33210

(b) Plot the continuous time signal x(t) =t\(t^2+4).

t=0:0.001:2;
A=5;
x=t\(t.^2+4);
plot (t,x)
grid on
title(' Continuous time signal')
xlabel('t')
ylabel('A')

You might also like