You are on page 1of 25

Ex.

No: 01
GENERATION AND OPERATION ON SIGNALS
DATE: 28/1/23

AIM:
To write a program using MATLAB, SciLab, and Kit Program to generate the
following signals and perform the operations on signals.
1. Unit Impulse Waveform
2. Unit Step Waveform
3. Ramp Waveform
4. Parabolic Waveform
5. Sine and Cosine Waveform
6. Exponential Waveform
7. Operations of Signals

TOOLS REQUIRED:
MATLAB, SciLab Software, 6713 DSP Processor.

THEORY:
CONTINUOUS SIGNAL:
The signals defined for every instant of time are known as
continuous or continuous-time signals. The continuous signal is also referred to as an analog
signal. They are continuous in both time and amplitude. Most of the signals that are
encountered in real-time are continuous.

DISCRETE SIGNAL:
The signals that are defined at discrete instants of time are known as
discrete-time signals. A time series is a function over a domain of integers. A discrete signal
is continuous in amplitude but discrete in time. A discrete time signal is obtained by sampling
the continuous signal.
MATHEMATICAL EQUATIONS:
CONTINUOUS TIME SIGNAL

x  t  = δ  t  = 1 , for t = 0 
Impulse = 0 , otherwise
sequence
 

x  t  = u  t  = 1 , for t  0 
Step sequence = 0 , otherwise
 

x  t  = r  t  = t , for t  0 
Ramp sequence = 0, otherwise
 
t 2

 ,t0
Parabolic Signal p(t) 
2 
 0 ,t0

eat , a  0 exponenonentially increasing

Exponential Signal x(t)  1 a  0 constantant magnitude
, at
e , a  0 exponenonentially decaying

Sinusoidal signal x  t  = Asinωt

DISCRETE-TIME SIGNAL

x  n  = δ  n  = 1 , for n = 0 
Impulse sequence = 0, otherwise

 

x  n  = u  n  = 1, for n > 0 
Step sequence 0, otherwise

 

x  n  = r  n  = n, for n  0 
Ramp sequence  
= 0, otherwise
 

 n2

Parabolic p(n)   2 , n  0
Signal
 0 ,n0

an , a  1 exponenonentially increasing
n
Exponential Signal x(n)  a , 0  a  1 exponenonentially decaying
 n
a , a  0 signal with oppositesign

Sinusoidal Signal: x  n  = Asinωn

OPERATIONS ON SIGNALS

Time Shifting:
Continuous time signal : y(t) = x (t - T)
Discrete-time signal : y(n) = y (n - N)
Time Reversal:
Continuous time signal : y(t) = x(-t)
Discrete-time signal : y(n) = x(-n)
Time Scaling:
Continuous time signal : y(t) = x(At)
A > 1, signal is compressed,0 < A < 1, signal is
expanded Discrete-time signal: y(n) = x(Dn)
y(n) = x(Dn), D*n -Down sampling, D/n – Up sampling
Addition:
Continuous time signal : y(t) = x1(t) + x2(t)
Discrete time signal : y(n) = x1(n) + x2(n)
Multiplication:
Continuous time signal : y(t) = x1(t) * x2(t)
Discrete time signal : y(n) = x1(n) * x2(n)
Amplitude Scaling :
Continuous time signal : y(t) = A*x(t)
Discrete time signal : y(n) = A*x(n)
PROGRAM:
MATLAB PROGRAM

A) TO GENERATE UNIT IMPULSE AND UNIT STEP FUNCTION:


clc
close all
clearall
figure(1)
% GENERATION OF IMPULSE SIGNAL IN CONTINUOUS TIME
x=-10:10;
z=[zeros(1,10),ones(1,1), zeros(1,10)];
subplot(2,2,1)
plot(x,z)
xlabel('Time')
ylabel('Amplitude')
title('Unit impulse signal for C.T')
%GENERATION OF UNIT IMPULSE SIGNAL FOR DISCRETE TIME
t=-10:10;
z=[zeros(1,10), ones(1,1) ,zeros(1,10)];
subplot(2,2,2)
stem(t,z)
xlabel('Time')
ylabel('Amplitude')
title('Unit impulse signal for D.T')
%GENERATION OF UNIT STEP SIGNAL FOR CONTINUOUS TIME
x1=-10:10;z=[zeros(1,10),ones(1,11)];
subplot(2,2,3)
plot(x1,z)
xlabel('Time')
ylabel('Amplitude')
title('Unit impulse signal for C.T')
%GENERATION OF UNIT STEP SIGNAL FOR DISCRETE-TIME
t1=-10:10;
z=[zeros(1,10), ones(1,11) ];
subplot(2,2,4)
stem(t1,z)
xlabel('Time')
ylabel('Amplitude')
title('Unit impulse signal for D.T')

B) TO GENERATE UNIT RAMP FUNCTION AND PARABOLIC SIGNAL:


figure(2)
%GENERATION OF RAMP SIGNAL FOR CONTINUOUS TIME
t=0:10;
z=t;
subplot(2,2,1)
plot(t,z)
xlabel('Time')
ylabel('Amplitude')
title('Ramp signal for C.T')
%GENERATION OF RAMP SIGNAL FOR DISCRETE TIME
t1=0:10;
z1=t;
subplot(2,2,2)
stem(t1,z)
xlabel('Time')
ylabel('Amplitude')
title('Ramp signal for D.T')
%GENERATION OF PARABOLIC SIGNAL FOR CONTINUOUS TIME
t2=1:10;
z2=(t2.^2)/2;
subplot(2,2,3)
plot(t2,z2)
xlabel('Time')
ylabel('Amplitude')
title('Parabolic signal for C.T ')
%GENERATION OF PARABOLIC SIGNAL FOR DISCRETE-TIME
t3=1:10;
z3=(t3.^2)/4;
subplot(2,2,4)
stem(t3,z3)
xlabel('Time')
ylabel('Amplitude')
title('Parabolic signal for D.T')

C) TO GENERATE SINE WAVEFORM AND COSINE WAVE SIGNAL:


figure(3)
%GENERATION OF SINE WAVE SIGNAL FOR CONTINUOUS TIME
t=0:0.1:2;
f=1;
A=4;
x1=A*sin(2*pi*f*t);
subplot(2,2,1)
plot(t,x1)
xlabel('Time')
ylabel('Amplitude')
title('Sine wave signal for C.T')
%GENERATION OF SINE WAVE SIGNAL FOR DISCRETE TIME
t1=0:0.1:2;
f=1;
A=4;
y1=A*sin(2*pi*f*t);
subplot(2,2,2)
stem(t1,y1)
xlabel('Time')
ylabel('Amplitude')
title('Sine wave signal for D.T')
%GENERATION OF COSINE WAVE SIGNAL FOR CONTINUOUS TIME
t=0:0.1:2;
f=1;
A=4;
x1=A*cos(2*pi*f*t);
subplot(2,2,3)
plot(t,x1)
xlabel('Time')
ylabel('Amplitude')
title('Cosine wave signal for C.T')
%GENERATION OF COSINE WAVE SIGNAL FOR DISCRETE TIME
t1=0:0.1:2;
f=1;
A=4;
y1=A*cos(2*pi*f*t);
subplot(2,2,4)
stem(t1,y1)
xlabel('Time')
ylabel('Amplitude')
title('Cosine wave signal for D.T')

D) TO PERFORM GENERATE EXPONENTIAL SIGNAL:


figure(4)
%GENERATION OF EXPONENTIAL SIGNAL FOR CONTINUOUS TIME
t=0:0.1:2;
b=3;
a=5;
x1=b*exp(a*t);
subplot(2,2,1)
plot(t,x1)
xlabel('Time')
ylabel('Amplitude')
title('Exponential signal for C.T')
%GENERATION OF EXPONENTIAL SIGNAL FOR DISCRETE TIME
t=0:0.1:2;
b=3;
a=5;
y1=b*exp(a*t);
subplot(2,2,2)
stem(t,y1)
xlabel('Time')
ylabel('Amplitude')
title('Exponential signal for D.T')
%GENERATION OF EXPONENTIAL SIGNAL FOR CONTINUOUS TIME
t=0:0.1:2;
b=3;
a=-5;
x1=b*exp(a*t);
subplot(2,2,3)
plot(t,x1)
xlabel('Time')
ylabel('Amplitude')
title('Exponential signal for C.T')
%GENERATION OF EXPONENTIAL SIGNAL FOR DISCRETE-TIME
t=0:0.1:2;
b=3;
a=-5;
y1=b*exp(a*t);
subplot(2,2,4)
stem(t,y1)
xlabel('Time')
ylabel('Amplitude')
title('Exponential signal for D.T')

E) TO PERFORM TIME SHIFTING, TIME SCALING, TIME REVERSAL &


AMPLITUDE SCALING:
%TIME SHIFTING DELAY
figure(5)
n=2:8;
x=[0,1,2,3,4,5];
p=n-2;
subplot(2,2,1);
stem(n,p);
xlabel('time');
ylabel('amplitude')
title('time shifting delay');
%TIME SHIFTING ADVANCE
n1=2:8;
x1=[0,1,2,3,4,5];
p1=n1+2;
subplot(2,2,2);
stem(n1,p1);
xlabel('time');
ylabel('amplitude')
title('time shifting
advance');
%TIME REVERSAL
n2=2:7;
x2=[0,1,2,3,4,5];
subplot(2,2,3);
stem(-n2,x2);
xlabel('time');
ylabel('amplitude')
title('time reversal');
%AMPLITUDE SCALING
n3=2:7;
x3=[0,1,2,3,4,5];
subplot(2,2,4);
stem(n3,x3);
xlabel('time');
ylabel('amplitude')
title( 'amplitude scaling');

SCILAB PROGRAM

A) TO GENERATE UNIT IMPULSE AND UNIT STEP FUNCTION:


figure(1)
// GENERATION OF IMPULSE SIGNAL IN CONTINUOUS TIME
x=-10:10;
z=[zeros(1,10),ones(1,1), zeros(1,10)];
subplot(2,2,1)
plot(x,z)
xlabel('Time')
ylabel('Amplitude')
title('Unit impulse signal for C.T')
//GENERATION OF UNIT IMPULSE SIGNAL FOR DISCRETE-TIME
t=-10:10;
z=[zeros(1,10), ones(1,1) ,zeros(1,10)];
subplot(2,2,2)
plot2d3(t,z)
xlabel('Time')
ylabel('Amplitude')
title('Unit impulse signal for D.T')
//GENERATION OF UNIT STEP SIGNAL FOR CONTINUOUS TIME
x1=-10:10;
z=[zeros(1,10),ones(1,11)];
subplot(2,2,3)
plot(x1,z)
xlabel('Time')
ylabel('Amplitude')
title('Unit step signal for C.T')
//GENERATION OF UNIT STEP SIGNAL FOR DISCRETE TIME
t1=-10:10;
z=[zeros(1,10), ones(1,11) ];
subplot(2,2,4)
plot2d3(t1,z)
xlabel('Time')
ylabel('Amplitude')
title('Unit step signal for D.T')

B) TO GENERATE UNIT RAMP FUNCTION AND PARABOLIC SIGNAL:


figure(2)
//GENERATION OF RAMP SIGNAL FOR CONTINUOUS TIME
t=0:10;
z=t;
subplot(2,2,1)
plot(t,z)
xlabel('Time')
ylabel('Amplitude')
title('Ramp signal for C.T')
//GENERATION OF RAMP SIGNAL FOR DISCRETE TIME
t1=0:10;
z1=t;
subplot(2,2,2)
plot2d3(t1,z)
xlabel('Time')
ylabel('Amplitude')
title('Ramp signal for D.T')
//GENERATION OF PARABOLIC SIGNAL FOR CONTINUOUS TIME
t2=1:10;
z2=(t2.^2)/2;
subplot(2,2,3)
plot(t2,z2)
xlabel('Time')
ylabel('Amplitude')
title('Parabolic signal for C.T ')
//GENERATION OF PARABOLIC SIGNAL FOR DISCRETE-TIME
t3=1:10;
z3=(t3.^2)/4;
subplot(2,2,4)
plot2d3(t3,z3)
xlabel('Time')
ylabel('Amplitude')
title('Parabolic signal for D.T')

C) TO GENERATE SINE WAVE AND COSINE WAVE SIGNALS:


figure(3)
//GENERATION OF SINE WAVE SIGNAL FOR CONTINUOUS TIME
t=0:0.1:2;
f=1;
A=4;
x1=A*sin(2*3.14*f*t);
subplot(2,2,1)
plot(t,x1)
xlabel('Time')
ylabel('Amplitude')
title('Sine wave signal for C.T')
//GENERATION OF SINE WAVE SIGNAL FOR DISCRETE-TIME
t1=0:0.1:2;
f=1;
A=4;
y1=A*sin(2*3.14*f*t);
subplot(2,2,2)
plot2d3(t1,y1)
xlabel('Time')
ylabel('Amplitude')
title('Sine wave signal for D.T')
//GENERATION OF COSINE WAVE SIGNAL FOR CONTINUOUS TIME
t=0:0.1:2;
f=1;
A=4;
x1=A*cos(2*3.14*f*t);
subplot(2,2,3)
plot(t,x1)
xlabel('Time')
ylabel('Amplitude')
title('Cosine wave signal for C.T')
//GENERATION OF COSINE WAVE SIGNAL FOR DISCRETE TIME
t1=0:0.1:2;
f=1;
A=4;
y1=A*cos(2*3.14*f*t);
subplot(2,2,4)
plot2d3(t1,y1)
xlabel('Time')
ylabel('Amplitude')
title('Cosine wave signal for D.T')
D)TO GENERATE EXPONENTIAL SIGNAL:
figure(4)
//GENERATION OF EXPONENTIAL SIGNAL FOR CONTINUOUS TIME
t=0:0.1:2;
b=3;
a=5;
x1=b*exp(a*t);
subplot(2,2,1)
plot(t,x1)
xlabel('Time')
ylabel('Amplitude')
title('Exponential signal for C.T')
//GENERATION OF EXPONENTIAL SIGNAL FOR DISCRETE TIME
t=0:0.1:2;
b=3;
a=5;
y1=b*exp(a*t);
subplot(2,2,2)
plot2d3(t,y1)
xlabel('Time')
ylabel('Amplitude')
title('Exponential signal for D.T')
//GENERATION OF EXPONENTIAL SIGNAL FOR CONTINUOUS TIME
t=0:0.1:2;
b=3;
a=-5;
x1=b*exp(a*t);
subplot(2,2,3)
plot(t,x1)
xlabel('Time')
ylabel('Amplitude')
title('Exponential signal for C.T')
//GENERATION OF EXPONENTIAL SIGNAL FOR DISCRETE TIME
t=0:0.1:2;
b=3;
a=-5;
y1=b*exp(a*t);
subplot(2,2,4)
plot2d3(t,y1)
xlabel('Time')
ylabel('Amplitude')
title('Exponential signal for D.T')

E) TO PERFORM TIME SHIFTING, TIME SCALING, TIME REVERSAL &


AMPLITUDE SCALING:
//TIME SHIFTING DELAY
figure(5)
n=2:8;
x=[0,1,2,3,4,5];
p=n-2;
subplot(2,2,1);
plot2d3(n,p);
xlabel('time');
ylabel('amplitude')
title('time shifting delay');
//TIME SHIFTING ADVANCE
n1=2:8;
x1=[0,1,2,3,4,5];
p1=n1+2;
subplot(2,2,2);
plot2d3(n1,p1);
xlabel('time');
ylabel('amplitude')
title('time shifting
advance');
//TIME REVERSAL
n2=2:7;
x2=[0,1,2,3,4,5];
subplot(2,2,3);
plot2d3(-n2,x2);
xlabel('time');
ylabel('amplitude')
title('time reversal');
//AMPLITUDE SCALING
n3=2:7;
x3=[0,1,2,3,4,5];
subplot(2,2,4);
plot2d3(n3,x3);
xlabel('time');
ylabel('amplitude')
title( 'amplitude scaling');

KIT PROGRAM

GENERATION OF SINE SIGNAL


#include<stdio.h>
#include<math.h>
float a[100];
main()
{
int i;
for(i=0;i<99;i++)
{
a[i]=10*sin(2*3.14*5*i/100);
printf(“%f”,a[i]);
}
}
GENERATION OF COSINE SIGNAL
#include<stdio.h>
#include<math.h>
float a[100];
main()
{
int i;
for(i=0;i<99;i++)
{
a[i]=10*cos(2*3.14*5*i/100);
printf(“%f”,a[i]);
}
}

MATLAB OUTPUTS

UNIT IMPULSE SIGNAL & UNIT STEP SIGNAL:


RAMP SIGNAL AND PARABOLIC SIGNAL:

SINUSOIDAL SIGNAL AND COSINE SIGNAL:


EXPONENTIAL SIGNAL:

TIME SHIFTING, TIME SCALING, TIME REVERSAL & AMPLITUDE SCALING:


SCILAB OUTPUTS

UNIT STEP SIGNAL&UNIT IMPULSE SIGNAL:

RAMP SIGNAL&PARABOLIC SIGNAL:


SINUSOIDAL SIGNAL AND COSINE SIGNAL:

EXPONENTIAL SIGNAL:
TIME SHIFTING, TIME SCALING, TIME REVERSAL & AMPLITUDE SCALING:
KIT OUTPUT

SINE WAVE:
COSINE WAVE:
RESULT:

Thus, various signals were generated and its various operations were performed in
MATLAB, SciLab, and Kit was executed successfully.

You might also like