Genaration of various signals and sequences
Aim: To generate different types of signals Using MATLAB Software.
EQUIPMENTS:
PC with windows OS
MATLAB Software
THEORY : If the amplitude of the signal is defined at every instant of time then it is called continuous signal. If the amplitude of the signal is defined at only at some instants of time then, it is called discrete signal. If the signal repeats itself at regular intervals of time, then it is called periodic signal. Otherwise, they are called aperiodic signals.
1.UNIT IMPULSE: a) Continuous signal:
and
Also called unit impulse function. The value of delta function can also be defined in the sense of generalized function
b) Unit Sample sequence:
Matlab program:
i) UNIT IMPULSE SIGNAL
clc;
clear all;
close all;
t=5:0.001:5
i=find(t==0);
x=zeros(1,length(t));
x(i)=1;
plot(t, x)
xlabel('time')
ylabel('amplitude')
title('unit impulse function')]
Output:
ii) unit Impulse sequence
clc;
clear all;
close all;
n=5:1:5
i=find(n==0);
x=zeros(1,length(n));
x(i)=1;
stem(n, x)
xlabel('time')
ylabel('amplitude')
title('unit impulse function')
Output:
2) Unit Step Function u(t):
b)Unit Step Sequence u(n): )={ 1, n = 0
0, n < 0
iii) Unit step generation
clc;
clear all;
close all;
t=10:0.01: 10;
x=zeros(1,length(t));
i=find(t==0);
x(i:length(x))=1;
plot(t, x)
xlabel('time')
ylabel('amplitude')
title('Unit Step Signal')
axis([5 5 1 2])
OUTPUT:
iv) Unit Step Sequence
clc;
clear all;
close all;
t=10:1: 10;
x=zeros(1,length(t));
i=find(t==0);
x(i:length(x))=1;
stem(t, x)
xlabel('time')
ylabel('amplitude')
title('Unit Step Sequence')
axis([5 5 1 2])
OUTPUT:
3. Square waves: Like sine waves, square waves are described in terms of period, frequency and amplitude:
Peak amplitude, Vp , and peaktopeak amplitude, Vpp , are measured as you might expect. However, the rms amplitude, Vrms , is greater than that of a sine wave. Remember that the rms amplitude is the DC voltage which will deliver the same power as the signal. If a square wave supply is connected across a lamp, the current flows first one way and then the other. The current switches direction but its magnitude remains the same. In other words, the square wave delivers its maximum power throughout the cycle so that Vrms is equal to Vp .
Although a square wave may change very rapidly from its minimum to maximum voltage, this change cannot be instaneous. The rise time of the signal is defined as the time taken for the voltage to change from 10% to 90% of its maximum value. Rise times are usually very short, with duration measured in nanoseconds (1 ns = 10^(9) s), or microseconds (1 µs = 10^(6)s), as indicated in the graph
v) Square wave wave generator
fs = 1000;
t = 0:1/fs:1.5;
x1 = square(2*pi*50*t);
subplot(1,2,1),plot(t,x1), axis([0 0.2 1.2 1.2])
xlabel('Time (sec)');ylabel('Amplitude'); title('Square Periodic Wave');
subplot(1,2,2),plot(t,x2), axis([0 0.2 1.2 1.2])
xlabel('Time (sec)');ylabel('Amplitude'); title('discrete Square Periodic Wave');
OUTPUT:
4. Sawtooth Waveform Generation
The sawtooth wave is a nonsinusoidal waveform. It is named a sawtooth based on its resemblance to the teeth on the blade of a saw. The convention is that a sawtooth wave ramps upward and then sharply drops. However, there are also sawtooth waves in which the wave ramps downward and then sharply rises. The latter type of sawtooth wave is called a 'reverse sawtooth wave' or 'inverse sawtooth wave'. As audio signals, the two orientations of sawtooth wave sound identical. The piece wise linear function based on the floor function of time t, is an example of a saw tooth wave with period1.
vi) Sawtooth wave generator
fs = 10000;
t = 0:1/fs:1.5;
x = sawtooth(2*pi*50*t);
subplot(1,2,1);
plot(t,x), axis([0 0.2 1 1]);
xlabel('t'),ylabel('x(t)')
title('sawtooth signal');
N=2; fs = 500;n = 0:1/fs:2;
x = sawtooth(2*pi*50*n);
subplot(1,2,2);
stem(n,x), axis([0 0.2 1 1]);
xlabel('n'),ylabel('x(n)')
title('sawtooth sequence');
OUTPUT:
Another method for generation Sawtooth waveform
vii) Sawtooth waveform
It is defined as x(t)=t for 0<t<T;
=0 elsewhere.
clc;
clear all;
close all;
fs=input('enter the value of sampling frequency')
T=1/fs;
t=0:T/fs:T;
p=zeros(1,length(t));
c=input('enter the duration of the pulse interms of number of time instances to be included')
for i=2:c
p(i)=p(i1)+1;
end
plot(t,p)
title('sawtooth signal')
xlabel('time')
ylabel('amplitude')
Result:
enter the value of sampling frequency 1000
fs = 1000
enter the duration of the pulse interns of number of time instances to be included 500
c = 500
OUTPUT:
viii) Saw tooth sequence
clc;
clear all;
close all;
fs=input('enter the value of sampling frequency')
T=1/fs;
t=0:T/fs:T;
p=zeros(1,length(t));
c=input('enter the duration of the pulse interms of number of time instances to be included')
for i=2:c
p(i)=p(i1)+1;
end
stem(t,p)
title('sawtooth sequence')
xlabel('time')
ylabel('amplitude')
Result:
enter the value of sampling frequency 100
fs = 100
enter the duration of the pulse interns of number of time instances to be included 50
c =50
OUTPUT:
ix) Sawtooth Pulse Train
fs=input('enter the value of sampling frequency')
T=1/fs;
t=0:T/fs:T;
p=zeros(1,length(t));
k=input('enter the number of cycles to be plotted')
c=input('enter the duration of the pulse interms of number of time instances to be included')
for i=2:c
p(i)=p(i1)+1;
end
t1=0:T/fs:k*T;
p1=zeros(1,length(t1));
p1(1:length(p)1)=p(1:length(p)1);
p(1)=[];
for i=1:k1
p1(i*length(p)+2:(i+1)*length(p)+1)=p
end
plot(t1,p1)
title('Sawtooth pulse Train')
xlabel('time')
ylabel('amplitude')
Result:
enter the value of sampling frequency 100
fs = 100
enter the number of cycles to be plotted 3
k =3
enter the duration of the pulse interms of number of time instances to be included 50
c =50
OUTPUT:
5. Triangular wave: A triangle wave is a nonsinusoidal waveform named for its triangular shape.A bandlimited triangle wave pictured in the time domain (top) and frequency domain (bottom). The fundamental is at 220 Hz (A2).Like a square wave, the triangle wave contains only odd harmonics.
x) To generate a triangular pulse
A=2; t = 0:0.0005:1;
x=A*sawtooth(2*pi*5*t,0.25); %5 Hertz wave with duty cycle 25%
plot(t,x);
grid
axis([0 1 3 3]);
OUTPUT:
xi) To generate a triangular pulse
fs = 10000;t = 1:1/fs:1;
x1 = tripuls(t,20e3); x2 = rectpuls(t,20e3);
subplot(211),plot(t,x1), axis([0.1 0.1 0.2 1.2])
xlabel('Time (sec)');ylabel('Amplitude'); 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')
set(gcf,'Color',[1 1 1])
OUTPUT:
6) Rectangular Pulse
xii) To generate a rectangular pulse
t=5:0.01:5;
pulse = rectpuls(t,2); %pulse of width 2 time units
plot(t,pulse)
axis([5 5 1 2]);
grid
6. Sinusoidal Signal Generation: It is a continues signal, it will vary the amplitude of the signal w.r.t time.
% sinusoidal signal
N=64; % Define Number of samples
n=0:N1; % Define vector n=0,1,2,3,...62,63
f=1000; % Define the frequency
fs=8000; % Define the sampling frequency
x=sin(2*pi*(f/fs)*n); % Generate x(t)
plot(n,x); % Plot x(t) vs. t
title('Sinewave [f=1KHz, fs=8KHz]');
xlabel('Sample Number');
ylabel('Amplitude');
% Program to generate a Sinusoidal sequence
clc;
clear all;
close all;
f=input('enter the frequency of the signal');
i=input('enter the no.of cycles to be plotted')
T=i/f;
t=0:T/f:T;
x=sin(2*pi*f*t);
stem(t, x)
title('sinusoidal sequence’)
xlabel(‘time’)
ylabel(‘amplitude’)
Result:
enter the frequency of the signal :100
enter the no.of cycles to be plotted:3
i = 3
OUTPUT:
7. RAMP
Ramp Signal:
It is defined as x(t)=t for t=0
= 0 elsewhere
% Program to generate ramp Signal
t=0:0.1:1;
x=0;
for i=2:length(t)
x(i)=x(i1)+2;
end
plot(t, x)
grid
title(' Ramp Signal ')
xlabel('time')
ylabel('amplitude')
OUTPUT
% Program to generate discrete ramp signal
t=0:0.1:1;
x=0;
for i=2:length(t)
x(i)=x(i1)+2;
end
stem(t, x)
grid
title(' Ramp Signal ')
xlabel('time')
ylabel('amplitude')
OUTPUT:
8. SINC FUNCTION:
% sinc
x = linspace(5,5);
y = sinc(x);
subplot(1,2,1);plot(x,y)
xlabel(‘time’);
ylabel(‘amplitude’);
title(‘sinc function’);
subplot(1,2,2);stem(x,y);
xlabel(‘time’);
ylabel(‘amplitude’);
title(‘sinc function’);
Result: In this experiment various signals have been generated Using MATLAB
Viva Questions:
1. Define Signal?
Ans: Signal is function of one or more variables to convey information.
2. Define deterministic?
Ans:Signal that can be modeled exactly by a mathematical formula is known as determistic signal
3. Define Random Signal?
Ans: Random signals are random variables which evolve, often with time (e.g. audio noise), but also with distance (e.g. intensity in an image of a random texture), or sometimes another parameter.
4.What is a duty cycle and give the duty cycle for a Square wave?
Ans: Duty cycle=T1/T1+T2.
Duty cycle of squrewave=50%
5. Define Periodic and a periodic Signal.
Ans: If x(t)=x(t+T) then x(t) is periodic signal otherwise it is aperiodic signal.

CreatedOct 16, 2019

UpdatedFeb 12, 2020

Views924
Basic operations on Matrices
Sampling theorem verification
Computation of unit sample, unit step and sinusoidal response of the given LTI system and verifying its physical reliability and stability properties
Finding the even and odd parts of signal/sequence and real and imaginary parts of signal
Auto correlation and cross correlation between signals and sequences
Genaration of various signals and sequences