Open In App

How To Generate Unit Step, Sinusoidal and Exponential Signal in MATLAB?

Last Updated : 18 Feb, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

A discrete-time signal is a function defined only at particular time instants. It is discrete in time but continuous in amplitude. An example is a temperature recorded at regular intervals of time in a day.

Unit Step Sequence

A unit step sequence is denoted as u(n) and is defined as.

u(n) =  { 1 for  n >=0       0 for      n< 0 }

Sinusoidal Sequence

A sinusoidal sequence is formed with the help sine or cosine function and it is denoted by x(n)=A cos(ωo. n +ϕ) where ωo is the frequency (in radian per sample) and ϕ is the phase (in radians).

Exponential Sequence

The exponential signal is a sequence of form x(n) = a^n  for all n. When the value of a>1, the sequence grows exponentially and when the value is 0<a<1, the sequence decays exponentially. Note also that when a<0, the discrete-time exponential signal takes alternating signs.

Addition Two Sinusoidal Signal

Adding two sinusoids of the same frequency but different amplitudes and phases gives output in another sinusoid (sin or cos) of the same frequency. The resulting amplitude and phase are different from the amplitude, and phase of the two original sinusoids.

Example 1:

Matlab

%Generation of discrete time sequence
%Generating a unit step sequence
 
N=21;
x=ones(1,N);
n=0:1:N-1;
subplot(2,2,1);
s=stem(n,x);
s.Color = 'green';
xlabel('n'),ylabel('x(n)');
title('Unit Step Sequence')
 
%Generating Sinusoidal Sequence
x1=sin(.2*pi*n);
subplot(2,2,2);
s=stem(n,x1);
s.Color = 'green';
xlabel('n'),ylabel('x2(n)');
title('Sinusoidal Sequence')
 
%Generating Exponential Sequence
x2=.8.^(n);
subplot(2,2,3);
s=stem(n,x2);
s.Color = 'green';
xlabel('n'),ylabel('x3(n)');
title('Exponential Sequence')
 
%Addition of two sinusoidal signal
x3=sin(.1*pi*n)+sin(.2*pi*n);
subplot(2,2,4);
s=stem(n,x3);
s.Color = 'green';
xlabel('n'),ylabel('x3(n)');
title('Addition of two Sinusoidal Sequence')

                    

Output:

 


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads