Skip to content
Advertisement

How to set all values between a range equal to zero in python [closed]

I want to set all the values between 0.75 and 0.8 of an array, equal to zero. Until now I have tried and succeeded to set all the values below or above a threshold equal to zero as it presented in the following code. cut_f_signal[0.75<abs(W)] = 0 but when I try with same command to put a range of values (0.75-0.8), cut_f_signal[0.75<abs(W)<0.8] = 0 , it doesn’t work, what shall I do?

Advertisement

Answer

cut_f_signal[(0.75<abs(W))&(abs(W)<0.8)] = 0 Should do it

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement