Saturday, June 25, 2011

MATLAB Programs 06: Generating a triangular waveform without using a sawtooth function

Below given is a program to generate the triangular waveform without using the sawtooth function.


%Program to generate triangular waveform



n=input ('Enter the length of the sequence N= ');
t=0:n;
y=(-1).^t; 
plot(t,y);
ylabel ('Amplitude');
xlabel ('Time Index');
TITLE ('Triangular waveform');


In the above program the concept of ramp signal is used. The slope of the ramp is changed alternatively to generate a triangular waveform. If two successive ramps are considered then one will be a positive going ramp and other will be a negative going ramp. Y signal i.e. the amplitude is expressed as the product of time index 't' and  power of -1 raised to time index. Thus for even time index the slope will be positive and for odd time index slope will be negative. Thus a triangular waveform is generated.

Now replace plot() with stem() and observe the result. You will not get the expected wave form. Think about the reason for it.

If you cannot make it out just post a comment here. 


9 comments:

Anonymous said...

nice job

Anonymous said...

very helpful.....frm PESCOE,A'bad

Anonymous said...

thanks..............pretty usefull

raj said...

IF I WANT SYMMETRICAL DISCRETE TRAINGULAR MEANS.............

Anonymous said...

Love it

S.P.Bharath Kumar said...

SoopeR

mahi said...

if we want at higher frequencies it cannot show then how we can proceed for higher frequencies around 1000hZ

Nikhil Bikumalla said...

I need code for stepped frequency continous waveform

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/




Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

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