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

Question:

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

Asked By: wosker4yan

||

Answers:

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()
Answered By: Ben Grossmann
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.