Wolfram Signal Processing | Things to Try
Wolfram Signal Processing | Things to Try
Make edits and run any piece of code by clicking inside the code and pressing .
+
Signal Processing & Analysis. Comprehensive signal processing capabilities, tightly bundled with powerful calculus, statistics and machine learning, for students and professionals in engineering, finance, medicine and more.
Lowpass IIR Butterworth Filter
Lowpass IIR Butterworth Filter
Create the analog Butterworth prototype of order n=3 ω c T=1 |
In[]:=
T=1;=;n=3;=Tan;tf=ButterworthFilterModel[{n,},s]//TransferFunctionExpand//Chop
ω
c
π
6
Ω
c
2.
T
ω
c
2
Ω
c
Create the corresponding digital filter using bilinear transformation: |
In[]:=
dtf=ToDiscreteTimeModel[tf,T,z]//Chop
Visualize the Bode plot of the filter: |
In[]:=
BodePlotdtf,{0,π},
Data Filtering with an IIR Filter
Data Filtering with an IIR Filter
Create a noisy sinusoidal signal: |
In[]:=
sig=TableSinn,{n,0,127}+RandomReal[{-0.25,0.25},128];
3.π
128
Define an IIR Butterworth filter: |
In[]:=
dtf=
;
0.153903 3 (1.+z) -4.70766+19.0258z-26.6767 2 z 3 z |
1
Filter the noisy signal: |
In[]:=
res=RecurrenceFilter[dtf,sig,Padding->None];ListPlot[{sig,res}]
Lowpass FIR Filter Using the Window Method
Lowpass FIR Filter Using the Window Method
Create a length L=17 ω c |
In[]:=
ω
c
π
6
ω
c
Apply a Hann window to the unit sample response: |
In[]:=
w=Array[HannWindow,L,{-0.5,0.5}];fir=wh
Show the frequency response of the resulting filter: |
In[]:=
PlotEvaluate[20Log10[Abs[ListFourierSequenceTransform[fir,ω]]]],{ω,0,π},
Data Filtering with an FIR Filter
Data Filtering with an FIR Filter
Create a noisy signal: |
In[]:=
sig=Table[SquareWave[n/64],{n,0,127}]+RandomReal[{-0.25,0.25},128];
Create a lowpass FIR filter: |
In[]:=
fir=LeastSquaresFilterKernel[{"Lowpass",π/6},17]Array[HannWindow,17,{-0.5,0.5}];
Filter the signal using |
In[]:=
res=ListConvolve[fir,sig,9];ListPlot[{sig,res}]
Equivalently, filter the signal using the |
In[]:=
ListPlot[{sig,LowpassFilter[sig,π/6,17,HannWindow,Padding->0]}]
Power Spectrum of a DTMF Signal
Power Spectrum of a DTMF Signal
Define a pair of dual-tone multi-frequency (DTMF) normalized frequencies (in radians/sample) for the dial-tone digit 2: |
In[]:=
{fp,fs}={697,1336};{wp,ws}=fp,fs
2π
8000.
2π
8000.
Create a dual-tone signal of approximately 200 ms duration: |
In[]:=
dtmf=Table[Sin[wpn]+Sin[wsn],{n,0,1799}]+RandomReal[{-0.25,0.25},1800];audio=AudioPad[Audio[dtmf,SampleRate8000],{0.02,0.02}]
Displays the power spectrum: |
In[]:=
Periodogramaudio,
Welch’s method averages power spectra of smoothed and overlapped partitions: |
In[]:=
Periodogramaudio,600,300,BlackmanWindow,
Signal Analysis Using a Spectrogram
Signal Analysis Using a Spectrogram
Define pairs of DTMF normalized frequencies (in radians/sample) for the dial-tone digits 9 and 1: |
In[]:=
freqs=#[[1]],#[[2]]&/@{{852,1447},{697,1209}}
2π
8000.
2π
8000.
Create an audio clip for the dual-tone sequence: |
In[]:=
dtmf=(Table[Sin[#[[1]]n]+Sin[#[[2]]n],{n,0,1799}]+RandomReal[{-0.25,0.25},1800]&)/@freqs;audio=AudioJoin[AudioPad[Audio[#,SampleRate8000],{0.01,0.01}]&/@dtmf]
View the spectrogram: |
In[]:=
Spectrogramaudio,
Improve the frequency resolution by increasing the segment length: |
In[]:=
Spectrogramaudio,512,
Additionally, improve the time resolution by increasing the overlap between segments: |
In[]:=
Spectrogramaudio,512,64,
Time Series Processing
Time Series Processing
Get daily temperature data. The data has a sampling period of T=1 T=86400 sr= 1 86400 |
In[]:=
ts=TimeSeries;
Smooth the data by applying a lowpass filter with a cutoff frequency approximating a weekly average: |
In[]:=
sr=1/86400;DateListPlotts,LowpassFilterts,sr,15,
π
6
Additionally, compute and visualize the approximate monthly average: |
In[]:=
DateListPlotts,LowpassFilterts,sr,15,LowpassFilterts,sr,65,
π
6
π
186