How can I create sine cosine and sawtooth signals in python

398 Views Asked by At

Hi there i want to construct a sine, cosine, and sawtooth signal with a frequency of 1 Hz and a sine signal with a frequency of 2 Hz. Examine whether these signals are orthogonal to each other. We are taken signal processing lecture but learning with matlab our mentor gave us a homework to do these in python and i dont know the syntax can anyone help me with these work ?

1

There are 1 best solutions below

0
Maximilian Freitag On
import math
import numpy as np
import matplotlib.pyplot as plt    


def sine(frequency, length, rate):
    length = int(length * rate)
    factor = float(frequency) * (math.pi * 2) / rate
    return np.sin(np.arange(length) * factor)


#Creating a sine signal with a frequency of 2Hz
def sine(t, f):
    return m.sin(2*math.pi*f*t)