-3

I would like to generate and plot a triangle wave of the amplitude of 2V and the frequency of 1 Hz using python. I would like to know the code thats does that as well as a simple explanation of each line. I googled that a lot and only found sin waveform ganeration in python and with limited explanation of the code used.
Think an answer is going to help lot of people getting started with signal processing in python. Thanks for reading, will appreciate any answer even a link to where the answer may lie.

YetAnotherBot
  • 1,937
  • 2
  • 25
  • 32
  • 1
    Welcome to StackOverflow. Please read and follow the posting guidelines in the help documentation, as suggested when you created this account. [On topic](http://stackoverflow.com/help/on-topic), [how to ask](http://stackoverflow.com/help/how-to-ask), and [... the perfect question](https://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/) apply here. StackOverflow is not a design, coding, research, or tutorial resource. However, if you follow whatever resources you find on line, make an honest coding attempt, and run into a problem, you'd have a good example to post. – Prune Dec 12 '18 at 20:46

1 Answers1

0

Found it ! For anyone looking out there your code is:

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

t = np.linspace(0, 4, 400)
plt.plot(t,2* signal.sawtooth(2 * np.pi * 1 * t,0.5))  
plt.xlabel("Time[s]")
plt.ylabel("Amplitude[V]")
plt.title("Singal for sampling")
plt.show()

Comments: Requires installation of scipy, matplotlib and numpy on the software you use to write code. For any questions on the code don't hesitate to contact me, Peace!