I want to make a square signal (as an array). I am trying the following code:
import numpy as np
x = np.linspace(0,2000, 100)
def func(x):
x = np.where(x<500 or x>530, 0, 2)
return x
y = func(x)
unfortunately, it throws the following error:
Traceback (most recent call last):
File "test.py", line 24, in <module>
y = func(x)
File "test.py", line 20, in func
x = np.where(x<500. or x>530, 0., 2.)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I do not understand what is wrong with my code.