0% found this document useful (0 votes)
660 views3 pages

Matlab Code for Step and Pulse Functions

This document contains Matlab programs that generate plots of common elementary signals including the unit step function, rectangular pulse, unit ramp function, triangular function, and unit impulse function. Each program defines the time and amplitude variables, plots the signal, and labels the axes. The output of each program is a visual representation of the signal.

Uploaded by

Manthan Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
660 views3 pages

Matlab Code for Step and Pulse Functions

This document contains Matlab programs that generate plots of common elementary signals including the unit step function, rectangular pulse, unit ramp function, triangular function, and unit impulse function. Each program defines the time and amplitude variables, plots the signal, and labels the axes. The output of each program is a visual representation of the signal.

Uploaded by

Manthan Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
  • Rectangular Pulse
  • Unit Step Function
  • Unit Ramp Function
  • Unit Impulse Function
  • Triangular Function

Matlab Programs for Elementary signals

 Unit Step Function: -


n= -10:10;
u= [zeroes (1,10) ones (1,11)];
stem(n,u);
axis (-12 12 -1 2);
title (‘Unit step’);
xlabel(‘Time’);
ylabel(‘Amplitude’);

Output:

 Rectangular Pulse: -
fs=500;
T=0.2;
t=-0.5:1/fs:0.5;
x=rectpuls (t, T);
plot (t, x,'K');
axis ([-0.5 0.5 0 2]);
title ('Rectangular pulse');
xlabel('Time');
ylabel('Amplitude');
Output: -

 Unit Ramp Function


n=input (‘enter value up to which you want to plot’);
t=[Link] n;
stem (t, t);
plot (t, t);
title (‘Ramp function’);
xlabel(‘Time’);
ylabel(‘Amplitude’);

Output: - 5
 Triangular Function: -
t=1:10;
x= [1 0 1 0 1 0 1 0 1 0];
plot (t, x);
title ('Triangular pulse');
xlabel('Time');
ylabel('Amplitude');
Output: -

 Unit Impulse Function: -


n= [-3:4];
y= [0 0 0 1 0 0 0 0];
stem (n, y);
title ('Unit Impulse function');
xlabel('Time');
ylabel('Amplitude');
Output: -

Matlab Programs for Elementary signals 
Unit Step Function: -
 
 
n= -10:10;
u= [zeroes (1,10) ones (1,11)];
stem(n,u);
axis
Output: -
                   
Unit Ramp Function
 
 
n=input (‘enter value up to which you want to plot’);
          t=0:1:
Triangular Function: -
 
 
t=1:10;
x= [1 0 1 0 1 0 1 0 1 0];
plot (t, x);
title ('Triangular pulse');
xlabel('Time');
ylabel

You might also like