Commits

Matti Pastell committed 4f03811

Terminal mode for code chunks working

Comments (0)

Files changed (1)

-Pweave Example - Frequency response of a moving average filter
-==============================================================
-
-:Author: Matti Pastell <matti.pastell@helsinki.fi>
-:Website: http://mpastell.com
-
-**Create 11 point moving average filter and plot its frequency response and print the values.**
-
-<<>>=
-from pylab import *
-import scipy.signal as signal
-#A function to plot frequency and phase response
-def mfreqz(b,a=1):
-    w,h = signal.freqz(b,a)
-    h = abs(h)
-    return(w/max(w), h)
-#Make the impulse response function
-@ 
-
-<<dtblock=True>>=
-n = 11.
-print(n)
-b = repeat(1/n, n)
-#Print impulse response of the filter
-print(b)
-@
-
-**Calculate the frequency response and plot it:**
-
-<<fig = True, width = '12 cm'>>=
-w, h = mfreqz(b)
-#Plot the function
-plot(w,h,'k')
-ylabel('Amplitude')
-xlabel(r'Normalized Frequency (x$\pi$rad/sample)')
-title('Frequency response of an 11 point \n moving average filter')
-show()
-@
-
-**Create a figure with a caption**
-
-<<fig = True, caption = 'Test figure'>>=
-plot(arange(10))
-show()
-@
-
-
-
-
-
-
-
-
-
+../pweavedocs/ma.Pnw