How to plot different discrete signal using MATLAB

1.Introduction:-
Here we are going to plot
1) unit impulse function
2) unit step signal
3) Ramp signal
4) sine signal
5) rising exponential
6) decaying exponential



2.Problem Statement:-
To plot different discrete signal using MATLAB.


3.Program:-

clc;
close all;
clear all;
n=-10:10;
% unit impulse function
a=1*(n==0);
subplot(3,2,1)
stem(n,a)
xlabel('n discrete time')
ylabel('magnitude')
title('unit impulse')
% unit step function
b=1*(n>=0)+0*(n<0);
subplot(3,2,2)
stem(n,b)
xlabel('n discrete time')
ylabel('magnitude')
title('unit step')
% unit ramp function
c=n.*(n>=0)+0*(n<0);
subplot(3,2,3)
stem(n,c)
xlabel('n discrete time')
ylabel('magnitude')
title('unit ramp')
% unit sine function
f=7/8;
mag=1
d=mag*sin(2*pi*f*n);
subplot(3,2,4)
stem(n,d)
xlabel('n discrete time')
ylabel('magnitude')
title('sine function')
% rising exponential function
e=2.^(n);
subplot(3,2,5)
stem(n,e)
xlabel('n discrete time')
ylabel('magnitude')
title('rising exponential function')
% decaying exponential function
f=2.^(-n);
subplot(3,2,6)
stem(n,f)
xlabel('n discrete time')
ylabel('magnitude')
title('decaying exponential function')

4.How to use this code:-
Here you have to only copy the code to MATLAB and just run it the result will appear on figure window.

5.Output :-


 Figure Window  


                                     



6.Conclusion -
Here we have successfully plot the different discrete signal using MATLAB.

Comments

Popular post

How to do VERNAM CIPHERING USING MATLAB CODE

How to plot AM (Amplitude Modulated) signal using MATLAB

How to add ,read,insert AUDIO in MATLAB