Saturday, June 25, 2011

MATLAB Programs 02: Generating an impulse signal


Below given is a program to generate an impulse signal. 


%program to generate Impulse Signal


t=-2:2;
y=zeros(1,5);
y(1,3)=1;
stem(t,y);
ylabel ('Amplitude');
xlabel ('Time Index');
TITLE ('Impulse Signal');


Here we have created an array Y with the following data 0,0,1,0,0. When this is compared to the time axis we get '1' for the time zero which represents the impulse signal.
Try plot(), instead of stem(). You may not get the required result. Guess the reason for it !!!. If you could not make it out ask me.

13 comments:

Anonymous said...

thanks

Anonymous said...

I just got a triangular shape when Plot() is used .. why ??

bala subramanian said...

is there a program for lightning surge

Anonymous said...

plot() gives a continous wave signal and marks the whole signal instead of the digital impulse value.

Thangaraj Thagnaraj said...

thank u

Anonymous said...

why y(1,3)=1 is used?? what is its significance? and if we change the value if y it shows error, say i have entered the value y=zeros(1,6) or y=zeros(1,7). can u plz help me.

Anonymous said...

i think plot is used for plotting continuous function and stem for discrete function.. that's why stem is used here

Anonymous said...

why we are using y=zeros(1,5) and y(1,3)=1 ?

Anonymous said...

n=-5:5;
m=2
x1=1*[(n+m)==0] %for impulse at n=-2
stem(n,x1)

Muhammad Zaka said...

y=zeros(1,5); why we are using this line??

Anonymous said...

for take five zeros in a single row

Nitesh Kumar said...

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/




GGWP said...

how do you use the dirac funtion to plot a unit impulse function?

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | coupon codes