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:

Thanks a lot

Rahul m.

how to sample it?

how to take its fft?

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

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

run nai ho raha bhadveee

tu khud gand maraaa

ghar jaake

randve

hijde

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

how can i generate sinc wave using matlab

## Post a Comment