You are on page 1of 6

Exercise 1:

%Generate a vector from -5 to 10


clf; %clear old graph
n= -5:10
%Generate the unit impulse sequence
I= [zeros (1, 5) 1 zeros (1, 10)];
%Plot the unit impulse sequence
stem (n,I);
title (Unit Impulse Sequence)
xlabel(Time index n);
ylabel(Amplitude)
axis([-5 10 0 2])
Exercise 2:
%Generation of a real exponential sequence
clf;
n=0:20;
a=2;
k=0.2;
x=k*a.^n;
stem(n,x);
title(Exponential Sequence);
xlabel(Time index n);
ylabel(Amplitude);
Exercise 3:
%Generation of a complex exponential sequence
clf;
n=0:20
w=pi/6;
x=exp (j*w*n)
subplot(2,1,1);
stem(n,real(x));
xlabel(Time index n);
ylabel(Amplitude);
title(Real part);
subplot (2,1,2);
stem (n,imag(x));
xlabel(Time index n);
ylabel(Amplitude);
title (Imaginary part);

Expt.No.
Date:

Generation of Various Signals and Sequences

Aim:
To know and understand how to generate various signals and sequences in Matlab tool.
Softwares Required:
Matlab R2015a
Hardware Required:
A personnel Computer.
Procedures:
1.
2.
3.
4.

Open matlab File.


Type the program in the editor window.
Save the file with .m Extension and run the program.
Verify the output in the command Window.

Theory:
Generation of Sequences:
The Unit Delta (Impulse) function: is often called the discrete time impulse or the unit
impulse. It is denoted by [n].

Discrete Shifted Unit Impulse:

The Unit step function: The unit step, denoted by u(n), is defined by

Exercise 4:
%Generation of a sinusoidal sequence
n=0:40; %length of sequence
f=0.1; %Frequency
phase = 0;
A=1.5; %Amplitude
x=A*sin (2*pi*f*n-phase);
stem(n,x);
title ('Sinusoidal Sequence')
xlabel ('Time index n');
ylabel ('Amplitude')
axis ([0 40 -2 2]);
grid;
Exercise 5:
%Periodic waveform:
fs = 10000;
t = 0:1/fs:1.5;
x1 = sawtooth(2*pi*50*t);
x2 = square(2*pi*50*t);
subplot(211),plot(t,x1), axis([0 0.2 -1.2 1.2])
xlabel('Time (sec)');
ylabel('Amplitude');
title('Sawtooth Periodic Wave');
subplot(212)
plot(t,x2)
axis([0 0.2 -1.2 1.2]);
xlabel('Time (sec)');
ylabel('Amplitude');
title('Square Periodic Wave');
Exercise 6:
%Aperodic waveform
fs = 10000;
t = -1:1/fs:1;
x1 = tripuls(t,20e-3);
x2 = rectpuls(t,20e-3);
subplot(211)
plot(t,x1)
axis([-0.1 0.1 -0.2 1.2])
xlabel('Time (sec)');
ylabel('Amplitude');

and is related to the unit sample by

The Unit Ramp Function:

Exponential function:

Generation of signals:
The sinusoidal Function:

title('Triangular Aperiodic Pulse');


subplot(212)
plot(t,x2)
axis([-0.1 0.1 -0.2 1.2])
xlabel('Time (sec)');
ylabel('Amplitude');
title('Rectangular Aperiodic Pulse');
Exercise 7:
%Special functions
tc = gauspuls('cutoff',50e3,0.6,[],-40);
t1 = -tc : 1e-6 : tc;
y1 = gauspuls(t1,50e3,0.6);
t2 = linspace(-5,5);
y2 = sinc(t2);
subplot(211)
plot(t1*1e3,y1);
xlabel('Time (ms)');
ylabel('Amplitude');
title('Gaussian Pulse');
subplot(212),plot(t2,y2);
xlabel('Time (sec)');
ylabel('Amplitude');
title('Sinc Function');
Exercise 8:
%Pulse Train
T = 0 : 1/50E3 : 10E-3;
D = [0 : 1/1E3 : 10E-3 ; 0.8.^(0:10)]';
Y = pulstran(T,D,@gauspuls,10E3,.5);
subplot(211)
plot(t*1e9,yp);
axis([0 25 -0.2 1.2]);
xlabel('Time (ns)');
ylabel('Amplitude');
title('Rectangular Train');
subplot(212)
plot(T*1e3,Y)
xlabel('Time (ms)');
ylabel('Amplitude');
title('Gaussian Pulse Train');

Result:

You might also like