Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading