Below given is a MATLAB program to generate and plot a unit step signal/sequence.

**% Program to generate Unit Step sequence**

**n=input ('Enter the length of the step sequence N='); % Get the length of the require sequence from the user**

**t=0:n-1; % defines the time axis**

**y=ones(1,n); % defines an 1 x n matrix which is filled with ones**

**stem(t,y); %displays the data as lines**

**ylabel ('Amplitude'); % name the Y axis**

**xlabel ('Time Index'); %Name the x axis**

**TITLE ('Unit Step Signal'); % Giving the title for the plot**

**% Program to generate Unit Step signal**

**n=input ('Enter the lenght of the step sequence N='); % Get the length of the require sequence from the user**

**t=0:n-1; % defines the time axis**

**y=ones(1,n); % defines an 1 x n matrix which is filled with one**

**plot(t,y); % Plot the graph**

**ylabel ('Amplitude'); % name the Y axis**

**xlabel ('Time Index'); %Name the x axis**

**TITLE ('Unit Step Signal'); % Giving the title for the plot**

By this time you might have understood the difference between stem() and plot().

## 11 comments:

zzzzzzzzzzzzzzzzzzzzzzzzzz.................... srsly????

awsum macha..

elinda maga ishtu talent???

i am sitting in college lab. your program is damn useful boss.... kudos to u man..!!!

i want a step sequence with desired time period between two ones. for example i want 1st 'one' at time zero second 'one' at o.5th second etc.... how to do that?

%try this one

function [x,n]= impulsesequence(n0,n1,n2)

if ((n0<n1)|(n0<n2)|(n1<2))

error('ensure arguments satisfy n1<=n0,=n2')

end

n=[n1:n2];

x=[(n-n0)==0];

stem(n,x)

awsome

Hi... Can someone help me to sort out this problem ?

The step input in Matlab has a default initial value as 0 and final value at 1. The step change occurs at t=0.

I want to change the initial value and also the step time...using matlab code.........[For eg : from 1 to 2 at t=5s]

I found no possibilities of changing the default value...Is there any other possibility????

pls help me to find mat lab pgm of displaying the sequence (.8)^n u(n).

pls help me to find mat lab pgm of displaying the sequence (.8)^n u(n).

I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in MATLAB, kindly contact us http://www.maxmunus.com/contact

MaxMunus Offer World Class Virtual Instructor led training on MATLAB. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.

For Demo Contact us.

Nitesh Kumar

MaxMunus

E-mail: nitesh@maxmunus.com

Skype id: nitesh_maxmunus

Ph:(+91) 8553912023

http://www.maxmunus.com/

## Post a Comment