# Changing Amplitude & Frequency of numpy.sin(wt) in pylab

### Question

For part of another project, I just need to make a simple sine wave with some frequency f.

Changing "samples" gives some strange effects on the pylab plot and I just don't know why!

using samples=500 gives a plot with frequency = 1/50 Hz.

using samples=1000 gives a plot with frequency = 1/100 Hz.

then with larger samples like 5000 and 10000, the plotted wave changes amplitude along the t axis, in patterns.

``````import numpy as N
f = 10.
w = 2. * N.pi * f
time_interval = 100
samples = 5000
t = N.linspace(0, time_interval, samples)
y = N.sin(w * t)
pylab.plot(t, y)
pylab.show()
``````

Any help here would be great! I just want a basic sine wave but can't even seem to do that!

1
2
2/17/2011 12:33:48 PM

I think you have a slight misconception with `samples`. It only gives the resolution of time. Try to plot with `time_interval= 1` and vary the `samples` (Start with small values like 10 and increase it then gradually). You'll see.

4
2/17/2011 1:24:04 PM