Simulate impulsive signal and plotting
<p>im trying to plot an impulsive signal (Taken from a scientific paper), the equation of the impulsive signal is:
<a href="http://i.stack.imgur.com/Zxhig.png" rel="nofollow"><img src="http://i.stack.imgur.com/Zxhig.png" alt="Impact formula"></a></p>

<p>where:</p>

<p>Ar= Amplitude of the impulses and equals 1.5</p>

<p>fm= fault characteristic freq. equals to 50 Hz</p>

<p>f=resonant frequency equals to 2000 Hz</p>

<p>F=sampling freq. equals to 10 kHz</p>

<p>betha= decay parameter equals 500}</p>

<p>total of 20.000 samples are simulated for the signal</p>

<p>the corresponding plot of the simulated signal should look like:
<a href="http://i.stack.imgur.com/fNmH2.png" rel="nofollow"><img src="http://i.stack.imgur.com/fNmH2.png" alt="enter image description here"></a></p>

<p>what i did is is:</p>

<pre><code>#Constants:
A_r=1.5
f=2000
r=-0.01
F=10**3
f_m=50
b=500
y_plt=[]

def y(k):
    return A_r*np.sin(2*pi*f*(k-r*F/f_m)/F)*np.exp(-b*(k-r*F/f_m))/F
x=np.linspace(0,0.2,20000)
for i in x:
    y_plt.append(y(i))

fig=plt.figure(1)
ax=plt.subplot(111)
ax.plot(x,y_plt)
</code></pre>

<p>getting the next plot:</p>

<p><a href="http://i.stack.imgur.com/3KuZk.png" rel="nofollow"><img src="http://i.stack.imgur.com/3KuZk.png" alt="enter image description here"></a>plt.show()</p>

<p>(Wich is not similar to the plot needed xP)
So my question is if everyone knows what im doing wrong, also the r parameter is not given.
Greet.</p>

<p>--EDIT--</p>

<pre><code>#Constants:
A_r=1.5
f=2000
r0=2
F=10**4
f_m=50
b=500
y_plt=[]
y_sum=[]

def y(k,r):
    t=(k- r*F/f_m)/F
    return A_r*np.sin(2*pi*f*t)*np.exp(-b*t)

for j in np.linspace(0,20000,20000,endpoint=False):   #k
    for i in np.linspace(0,r0,r0,endpoint=False):   #r
        y_sum.append(y(j,i))
        pene=np.sum(y_sum)
    y_plt.append(pene)

plt.figure(1)        
plt.plot(np.linspace(0,20000,20000,endpoint=False),y_plt)
plt.show()
</code></pre>

<p>Now, what i cant figure out is how to make it an periodic signal. I think it has relation to the r factor, but if i change it doesnt change the plot at all.</p>

<p><a href="http://i.stack.imgur.com/jyj05.png" rel="nofollow"><img src="http://i.stack.imgur.com/jyj05.png" alt="Simple Impulse"></a></p>

<h1>1.</h1>

<blockquote>
  <p>F=sampling freq. equals to 10 kHz</p>
</blockquote>

<p>But you wrote</p>

<pre><code>F = 10 ** 3
</code></pre>

<p>In Python <code>**</code> mean exponentiation, so this is just 10<sup>3</sup> = 1000. That is, you have used F = 1 kHz in your code.</p>

<p>If you want to express 10.0 &times; 10<sup>3</sup>, use:</p>

<pre><code>F = 10e3
#     ^
</code></pre>

<h1>2.</h1>

<pre><code>A_r * np.sin(2*pi*f*(k-r*F/f_m)/F) * np.exp(-b*(k-r*F/f_m))/F
#                                    ^~~~~~~~~~~~~~~~~~~~~~~~
</code></pre>

<p>Compared with your equation</p>

<blockquote>
  <p><img src="http://i.stack.imgur.com/Zxhig.png" alt=""></p>
</blockquote>

<p>Note that the <code>/ F</code> part should be <em>inside</em> the <code>np.exp</code>, but you have put it outside.</p>

<p>There are so many parenthesis in the same line which mistakes can easily happen. You should better factor out the intermediate variable to make it easier to read:</p>

<pre><code>def y(k):
    t = (k - r*F/f_m) / F
    return A_r * np.sin(2*pi*f*t) * np.exp(-b*t)
</code></pre>

<h1>3.</h1>

<p>Note that your equation has a &sum;<sub>r</sub> &mdash; it is a summation of waves over many <em>r</em>. Are you sure A_r is just a single value?</p>

python numpy signal-processing