Open In App

How To Generate Periodic and Aperiodic Sequence in MATLAB?

The signal is an electric or electromagnetic current carrying data, that can be transmitted or received. Mathematically represented as a function of an independent variable e.g. density, depth, etc. Therefore, a signal is a physical quantity that varies with time, space or any other independent variable by which information can be conveyed

Periodic Sequence

Aperiodic Sequence

Example 1:




% Periodic and aperiodic sequences
clear all
n=0:1:50;
n1=0:1:50;
 
% sine wave with frequency w=0.2*pi
x1=sin(.2*pi*n);
 
% sine wave with frequency w=0.4*pi
x2=sin(.4*pi*n);
 
% sum of x1 and x2
x3=sin(.2*pi*n)+sin(.4*pi*n);
 
% aperiodic sequence
x4=sin(.5*n1);
 
% Periodic Sequence
subplot(2,2,1);
s1=stem(n,x1);
s1.Color='green';
xlabel('n'),ylabel('x1(n)')
axis([0 50 -1 1])
 
% Periodic Sequence
subplot(2,2,2);
s2=stem(n,x2);
s2.Color='green';
xlabel('n'),ylabel('x2(n)')
axis([0 50 -1 1])
 
% Aperiodic Sequence
subplot(2,2,3);
s3=stem(n,x3);
s3.Color='green';
xlabel('n'),ylabel('x3(n)')
axis([0 50 -2 2])
 
% Aperiodic Sequence
subplot(2,2,4);
s4=stem(n1,x4);
s4.Color='green';
xlabel('n'),ylabel('x4(n)')
axis([0 50 -1 1])

Output:

x1(n) & x2(n) Periodic Signals and x3(n) & x4(n) Aperiodic Signals

Article Tags :