i canot do it...please help me
I would like to perform the operation of convolution of sinus signal and rectangular pulse in scipy. I convolved sinus signal with cosinus signal and plotted that on the graph, but I would like to know how to create array with rectangular pulse, something similar to this matlab expression
y = rectpulse(x,nsamp)
so I can convolve them. I use this to create my sinus and cosinus signal
x=r_[0:50] (my array)
y01=sin(2*pi*x/49)
y02=cos(2*pi*x/49)
So i tried to create a nu.zeros(50), and manually changing the zeros from position 15-25 from 0.0. to 0.9 so it looks like rectangle but convolution on sinus array and this 'rectangle' array is weird, It is supposed to be zero when there is no intersection but i get sinus signal in return, here is the code:
from numarray import*
from numarray.fft import*
from pylab import*
x=r_[0:50]
y1=sin(2*pi*x/49)
#y2=cos(2*pi*x/49)
y2=np.zeros((y1.shap))
for i in range(15,25):
y2[i]=0.9
#print len(y1),len(y2)
#y3=convolve(y2,y1,mode="same")
y3=convolve(y2,y1)
subplot(2,2,1)
plot(x,y1)
hold(True)
plot(x,y2)
hold(True)
subplot(2,2,2)
print len(x),len(y3)
xx=r_[0:len(y3)]
print len(xx),len(y3)
plot(xx,y3)
hold(True)
show()
