Saturday, June 25, 2011

MATLAB Programs 05: Generating sine/cosine waveform

Below given is a program to generate sine waveform. Parameters for the sin() and cos() functions share same typical meaning.


%program to generate sine wave


f= input('enter the frequency in hertz of the sine wave'); 
t=0:.0001:5;
y=sin(2*pi*f*t);
plot(t,y);
ylabel ('Amplitude');
xlabel ('Time Index');
TITLE ('Sine wave');



%program to generate cosine wave


f= input('enter the frequency in hertz of the sine wave'); 
t=0:.0001:5;
y=cos(2*pi*f*t);
plot(t,y);
ylabel ('Amplitude');
xlabel ('Time Index');
TITLE ('cosine wave');





10 comments:

Anonymous said...

Thanks a lot



Rahul m.

Anonymous said...

how to sample it?

Anonymous said...

how to take its fft?

Anonymous said...

how can i make a sinusoidal generator with a variable frequency?

Anonymous said...

how to retain curve between time 2.5 to 3.5 and rest to be zero

Anonymous said...

run nai ho raha bhadveee

Anonymous said...

tu khud gand maraaa
ghar jaake
randve
hijde

Anonymous said...

uday prakash pethakamsetty said...

for the question: how to get fft,
ans is use fft command.

for the question : how to sample it?

ans: the output itself is a discrete signal. But, as the plot command is used,
you are getting a continuous representation.
But, you can change the sampling rate.

in second line,
t=0:.0001:5;
Here .0001 is the sampling period. change that value to change the sampling period, which in turn effects its inverse i.e., sampling frequency

Jibin Mathew said...

how can i generate sinc wave using matlab

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

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