How to change sawtooth function so it raises from 0.15 to 0.18 instead of -1 to 1

I would like to change the y axis so the wave raises from 0.15 and the peak is at 0.18. Instead of -1 to 1

from scipy import signal
import numpy as np
import matplotlib.pyplot as plt
t = np.linspace(0, 3, 500)
plt.plot(t, signal.sawtooth(np.pi * 4 * t))
plt.show()

enter image description here

>Solution :

You could do the following:

from scipy import signal
import numpy as np
import matplotlib.pyplot as plt

a = .15
b = .18
t = np.linspace(0, 3, 500)

y = (b+a)/2 + ((b-a)/2) * signal.sawtooth(np.pi * 4 * t)

plt.plot(t, y)
plt.show()

Leave a Reply