SlideShare a Scribd company logo
Introduction 1
Multirate Sampling Simulation Using
MATLAB’s Signal Processing Toolbox
Introduction
This technical note explains how you can very easily use the command line functions available in
the MATLAB signal processing toolbox, to simulate simple multirate DSP systems. The focus
here is to be able to view in the frequency domain what is happening at each stage of a system
involving upsamplers, downsamplers, and lowpass filters. All computations will be performed
using MATLAB and the signal processing toolbox. These same building blocks are available in
Simulink via the DSP blockset. The DSP blockset allows better visualization of the overall sys-
tem, but is not available in the ECE general computing laboratory or on most personal systems. A
DSP block set example will be included here just so one can see the possibilities with the addi-
tional MATLAB tools.
Command Line Building Blocks
To be able to visualize the spectra in a multirate system we need the basic building blocks of
• Bandlimited signal generation; here we create a signal with a triangle shaped spectrum using
sinc()
• Integer upsampling and downsampling operations; here we use the signal processing tool-
box functions upsample() and downsample()
• Lowpass filtering for antialiasing and interpolation; here we use fir1()
• If we don’t care to examine the spectra between the antialiasing lowpass filter and the deci-
mator or between the upsampler and interpolation filter, we can use combination functions
such as decimate(), interpolate(), and resample()
Signal Generation
In a theoretical discussion of sampling theory it is common place to represent the signal of interest
as having a triangular shaped Fourier spectrum. Another common signal type is one or more dis-
crete-time sinusoids. We know that
(1)
where
ωcnsin
πn
-----------------
ω
2ωc
---------
 
 
∏↔
F
x
W 2⁄W 2⁄–
1x
W
-----
 
 
∏ = W
ECE 5650/4650 Simulation with MATLAB
Command Line Building Blocks 2
A triangle can be obtained in the frequency domain by noting that
(2)
The periodic convolution on the right-side of (2) yields
where is the spectral bandwidth (single-sided or lowpass) in normalized frequency units. It
then follows that for a unit height spectrum we have the transform pair
(3)
where
Using the sinc( ) function in MATLAB, which is defined as
(4)
we can write (3) as
(5)
Creating a triangular spectrum signal in MATLAB just requires delaying the signal in samples so
that both tails can be represented in a causal simulation, e.g.,
>> n = 0:1024;
>> x = 1/4*sinc(1/4*(n-512)).^2; % set peak of signal to center of interval
>> f = -1:1/512:1; % create a custom frequency axis for spectral plotting
>> X = freqz(x,1,2*pi*f); %Compute the Fourier transform of x
>> plot(f,abs(X))
>> print -tiff -depsc multi1.eps
ωcn 2⁄( )sin
πn
-----------------------------
2
1
2π
------
ω θ–
ωc
-------------
 
  θ
ωc
------
 
 
∏∏ θd
π–
π
∫↔
F
ω
ωcω– c
ωc
2π
------ fc=
fc
2π
ωc
------
ωcn 2⁄( )sin
πn
-----------------------------
 
 
2
Λ
ω
ωc
------
 
 ↔
F
x
WW–
1
Λ
x
W
-----
 
  =
sinc x( )
πxsin
πx
--------------≡
fc sinc fcn( )[ ]
2
Λ
ω
2πfc
----------
 
 ↔
F
ECE 5650/4650 Simulation with MATLAB
Command Line Building Blocks 3
Consider a couple of more examples:
>> n = 0:1024;
>> x125 = 1/8*sinc(1/8*(n-512)).^2;
>> x5 = 1/2*sinc(1/2*(n-512)).^2;
>> f = -1:1/512:1;
>> X125 = freqz(x125,1,2*pi*f);
>> X5 = freqz(x5,1,2*pi*f);
>> subplot(211)
>> plot(f,abs(X125))
>> subplot(212)
>> plot(f,abs(X5))
>> print -tiff -depsc multi2.eps
Upsample and Downsample
With a means to generate a signal having bandlimited spectra in place, we can move on to the
upsampling and downsampling operations. The signal processing toolbox has dedicated functions
for doing this operation, although they are actually quite easy to write yourself.
>> help downsample
−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
Normalized Frequency
ω
2π
------
X e
jω
( )
fc 0.25 or ωc
π
2
---= =
−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1
0
0.5
1
−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1
0
0.5
1
Normalized Frequency
ω
2π
------
X e
jω
( )
X e
jω
( )
ωc
π
4
---=
ωc π=
ECE 5650/4650 Simulation with MATLAB
Command Line Building Blocks 4
DOWNSAMPLE Downsample input signal.
DOWNSAMPLE(X,N) downsamples input signal X by keeping every
N-th sample starting with the first. If X is a matrix, the
downsampling is done along the columns of X.
DOWNSAMPLE(X,N,PHASE) specifies an optional sample offset.
PHASE must be an integer in the range [0, N-1].
See also UPSAMPLE, UPFIRDN, INTERP, DECIMATE, RESAMPLE.
>> help upsample
UPSAMPLE Upsample input signal.
UPSAMPLE(X,N) upsamples input signal X by inserting
N-1 zeros between input samples. X may be a vector
or a signal matrix (one signal per column).
UPSAMPLE(X,N,PHASE) specifies an optional sample offset.
PHASE must be an integer in the range [0, N-1].
See also DOWNSAMPLE, UPFIRDN, INTERP, DECIMATE, RESAMPLE.
These functions will be used in examples that follow.
Filtering
To implement a simple yet effective lowpass filter to prevent aliasing in a downsampler and inter-
polation in an upsampler, we can use the function fir1() which designs linear phase FIR filters
using a windowed sinc function.
>> help fir1
FIR1 FIR filter design using the window method.
B = FIR1(N,Wn) designs an N'th order lowpass FIR digital filter
and returns the filter coefficients in length N+1 vector B.
The cut-off frequency Wn must be between 0 < Wn < 1.0, with 1.0
corresponding to half the sample rate. The filter B is real and
has linear phase. The normalized gain of the filter at Wn is
-6 dB.
More help beyond this, but this is the basic LPF design interface
The filter design functions use half sample rate normalized frequencies:
ω
f′
π 2π
10
Input on f′ axis
π M⁄
1 M⁄
To get this,
enter this
ECE 5650/4650 Simulation with MATLAB
System Simulation 5
To design a lowpass filter FIR filter having 128 coefficients and a cutoff frequency of ,
we simply type
>> h = fir1(128-1,1/3); % Input cutoff as 2*fc, where fc = wc/(2pi)
>> freqz(h,1,512,1)
>> print -tiff -depsc multi3.eps
System Simulation
To keep things simple we will consider just simple decimator and interpolator systems.
A Simple Decimation Example
In the above system we will consider the pure decimator and the decimator with lowpass prefilter-
ing. Two different values of M will be considered.
As a first example we pass directly into an decimator with a signal having
( ).
>> n = 0:1024;
ωc π 3⁄=
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
−6000
−4000
−2000
0
Frequency (Hz)
Phase(degrees)
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
−80
−60
−40
−20
0
Frequency (Hz)
Magnitude(dB)
Mx n[ ] y n[ ]
Lowpass
ωc
π
M
-----=
ω
ωNω– N
1X e
jω
( )
Bypass LPF
M 2=
ωN π 2⁄= fN 1 4⁄=
ECE 5650/4650 Simulation with MATLAB
System Simulation 6
>> x = 1/4*sinc(1/4*(n-512)).^2;
>> y = downsample(x,2);
>> f = -1:1/512:1;
>> X = freqz(x,1,2*pi*f);
>> Y = freqz(y,1,2*pi*f);
>> plot(f,abs(X))
>> subplot(211)
>> plot(f,abs(X))
>> subplot(212)
>> plot(f,abs(Y))
>> print -tiff -depsc multi4.eps
• The results are exactly as we would expect
Now, use the same signal except with . First without the prefilter, and then include it to
avoid aliasing.
>> n = 0:1024;
>> x = 1/4*sinc(1/4*(n-512)).^2;
>> xf = filter(h,1,x);
>> yf = downsample(xf,3);
>> ynf = downsample(x,3);
>> X = freqz(x,1,2*pi*f);
>> Xf = freqz(xf,1,2*pi*f);
>> Yf = freqz(yf,1,2*pi*f);
>> Ynf = freqz(ynf,1,2*pi*f);
>> subplot(411)
−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1
0
0.5
1
−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
Normalized Frequency
ω
2π
------
X e
jω
( )
Y e
jω
( )
L 2 Decimation, No Prefilter=
No aliasing
problems
M 3=
ECE 5650/4650 Simulation with MATLAB
System Simulation 7
>> plot(f,abs(X))
>> subplot(412)
>> plot(f,abs(Ynf))
>> subplot(413)
>> plot(f,abs(Xf))
>> subplot(414)
>> plot(f,abs(Yf))
>> print -tiff -depsc multi5.eps
A Simple Interpolation System
In the above system we will consider the pure upsampler and the upsampler followed by a low-
pass interpolation filter. Let and the signal have ( ).
>> n = 0:1024;
−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1
0
0.5
1
−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1
0
0.5
1
−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
Normalized Frequency
ω
2π
------
X e
jω
( )
Yf e
jω
( )
Xf e
jω
( )
Ynf e
jω
( )
Aliasing Aliasing
Unfiltered
Input
Filtered
Input
Down by 3
w/o Filter
Output
Down by 3
with Filter
OutputShould be 0
but filter is
not ideal
Lowpass
ωc
π
3
---=3 yr n[ ]x n[ ]
yu n[ ]
ω
ωNω– N
1X e
jω
( )
L 3= ωN π 2⁄= fN 1 4⁄=
ECE 5650/4650 Simulation with MATLAB
A DSP Blockset Example 8
>> x = 1/4*sinc(1/4*(n-512)).^2;
>> y = upsample(x,3);
>> X = freqz(x,1,2*pi*f);
>> Y = freqz(y,1,2*pi*f);
>> h = fir1(128-1, 1/3);
>> yf = filter(h,1,y);
>> Yf = freqz(yf,1,2*pi*f);
>> subplot(311)
>> plot(f,abs(X))
>> subplot(312)
>> plot(f,abs(Y))
>> subplot(313)
>> plot(f,abs(Yf))
>> print -tiff -depsc multi6.eps
A DSP Blockset Example
What can be accomplished at the MATLAB command line using just the signal processing tool-
box, can be enhanced significantly by adding Simulink and the DSP blockset. Simulink is a block
diagram based simulation environment that sits on top of MATLAB. The DSP blockset augments
Simulink with a DSP specific block library and requires that the signal processing toolbox be
present.
−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1
0
0.5
1
−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1
0
0.5
1
−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1
0
0.5
1
Normalized Frequency
ω
2π
------
X e
jω
( )
Yf e
jω
( )
Y e
jω
( )
Images removed
by lowpass filter
Input
Spectrum
Upsampled
by 3 Input
Interp.
Upsample
Output
ECE 5650/4650 Simulation with MATLAB
A DSP Blockset Example 9
As a simple example consider Text problem 4.15. The results are not shown here as they are in
the solutions to problem 4.15. A sinusoidal input can be connected (the plot currently off to the
side) or a signal vector from the MATLAB workspace can be used as the input. As shown above
the input from the workspace is a triangular spectrum signal. The upsampler and downsampler
blocks works just like the command line functions. The lowpass filter block has been designed
using a GUI filter design tool (FDA tool), but ultimately uses coefficients similar to those
obtained from MATLAB’s command line filter design tools. The To Workspace blocks allow the
signals to be exported to the MATLAB workspace for futher manipulation.
FDATool
wc = Pi/8 LPF
3
Upsample
simout2
To Workspace2
simout1
To Workspace1
simout
To Workspace
Sine Wave
simin
From
Workspace
3
Downsample
Simulation block diagram
for text problem 4.15

More Related Content

What's hot

Dft2
Dft2Dft2
D ecimation and interpolation
D ecimation and interpolationD ecimation and interpolation
D ecimation and interpolation
Suchi Verma
 
DSP_FOEHU - Lec 08 - The Discrete Fourier Transform
DSP_FOEHU - Lec 08 - The Discrete Fourier TransformDSP_FOEHU - Lec 08 - The Discrete Fourier Transform
DSP_FOEHU - Lec 08 - The Discrete Fourier Transform
Amr E. Mohamed
 
Dsp gcu lab11
Dsp gcu lab11Dsp gcu lab11
Dsp gcu lab11
Jannat41
 
Dsp Lab Record
Dsp Lab RecordDsp Lab Record
Dsp Lab Record
Aleena Varghese
 
Introduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and KerasIntroduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and Keras
Oswald Campesato
 
DSP_FOEHU - Lec 09 - Fast Fourier Transform
DSP_FOEHU - Lec 09 - Fast Fourier TransformDSP_FOEHU - Lec 09 - Fast Fourier Transform
DSP_FOEHU - Lec 09 - Fast Fourier Transform
Amr E. Mohamed
 
Working with tf.data (TF 2)
Working with tf.data (TF 2)Working with tf.data (TF 2)
Working with tf.data (TF 2)
Oswald Campesato
 
digital signal-processing-lab-manual
digital signal-processing-lab-manualdigital signal-processing-lab-manual
digital signal-processing-lab-manual
Ahmed Alshomi
 
DSP Mat Lab
DSP Mat LabDSP Mat Lab
Digital Signal Processing Lab Manual ECE students
Digital Signal Processing Lab Manual ECE studentsDigital Signal Processing Lab Manual ECE students
Digital Signal Processing Lab Manual ECE students
UR11EC098
 
A Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB SimulinkA Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB Simulink
Jaewook. Kang
 
Matlab programs
Matlab programsMatlab programs
Matlab programs
Prakash Rout
 
Effects of varying number of samples in an image
Effects of varying number of samples in an imageEffects of varying number of samples in an image
Effects of varying number of samples in an image
lakshmymk
 
Matlab code for comparing two microphone files
Matlab code for comparing two microphone filesMatlab code for comparing two microphone files
Matlab code for comparing two microphone files
Minh Anh Nguyen
 
Dsp lab manual
Dsp lab manualDsp lab manual
Dsp lab manual
Mukul Mohal
 
DSP_2018_FOEHU - Lec 06 - FIR Filter Design
DSP_2018_FOEHU - Lec 06 - FIR Filter DesignDSP_2018_FOEHU - Lec 06 - FIR Filter Design
DSP_2018_FOEHU - Lec 06 - FIR Filter Design
Amr E. Mohamed
 
DSP_FOEHU - Lec 03 - Sampling of Continuous Time Signals
DSP_FOEHU - Lec 03 - Sampling of Continuous Time SignalsDSP_FOEHU - Lec 03 - Sampling of Continuous Time Signals
DSP_FOEHU - Lec 03 - Sampling of Continuous Time Signals
Amr E. Mohamed
 
A Simple Communication System Design Lab #3 with MATLAB Simulink
A Simple Communication System Design Lab #3 with MATLAB SimulinkA Simple Communication System Design Lab #3 with MATLAB Simulink
A Simple Communication System Design Lab #3 with MATLAB Simulink
Jaewook. Kang
 
DSP_2018_FOEHU - Lec 08 - The Discrete Fourier Transform
DSP_2018_FOEHU - Lec 08 - The Discrete Fourier TransformDSP_2018_FOEHU - Lec 08 - The Discrete Fourier Transform
DSP_2018_FOEHU - Lec 08 - The Discrete Fourier Transform
Amr E. Mohamed
 

What's hot (20)

Dft2
Dft2Dft2
Dft2
 
D ecimation and interpolation
D ecimation and interpolationD ecimation and interpolation
D ecimation and interpolation
 
DSP_FOEHU - Lec 08 - The Discrete Fourier Transform
DSP_FOEHU - Lec 08 - The Discrete Fourier TransformDSP_FOEHU - Lec 08 - The Discrete Fourier Transform
DSP_FOEHU - Lec 08 - The Discrete Fourier Transform
 
Dsp gcu lab11
Dsp gcu lab11Dsp gcu lab11
Dsp gcu lab11
 
Dsp Lab Record
Dsp Lab RecordDsp Lab Record
Dsp Lab Record
 
Introduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and KerasIntroduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and Keras
 
DSP_FOEHU - Lec 09 - Fast Fourier Transform
DSP_FOEHU - Lec 09 - Fast Fourier TransformDSP_FOEHU - Lec 09 - Fast Fourier Transform
DSP_FOEHU - Lec 09 - Fast Fourier Transform
 
Working with tf.data (TF 2)
Working with tf.data (TF 2)Working with tf.data (TF 2)
Working with tf.data (TF 2)
 
digital signal-processing-lab-manual
digital signal-processing-lab-manualdigital signal-processing-lab-manual
digital signal-processing-lab-manual
 
DSP Mat Lab
DSP Mat LabDSP Mat Lab
DSP Mat Lab
 
Digital Signal Processing Lab Manual ECE students
Digital Signal Processing Lab Manual ECE studentsDigital Signal Processing Lab Manual ECE students
Digital Signal Processing Lab Manual ECE students
 
A Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB SimulinkA Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB Simulink
 
Matlab programs
Matlab programsMatlab programs
Matlab programs
 
Effects of varying number of samples in an image
Effects of varying number of samples in an imageEffects of varying number of samples in an image
Effects of varying number of samples in an image
 
Matlab code for comparing two microphone files
Matlab code for comparing two microphone filesMatlab code for comparing two microphone files
Matlab code for comparing two microphone files
 
Dsp lab manual
Dsp lab manualDsp lab manual
Dsp lab manual
 
DSP_2018_FOEHU - Lec 06 - FIR Filter Design
DSP_2018_FOEHU - Lec 06 - FIR Filter DesignDSP_2018_FOEHU - Lec 06 - FIR Filter Design
DSP_2018_FOEHU - Lec 06 - FIR Filter Design
 
DSP_FOEHU - Lec 03 - Sampling of Continuous Time Signals
DSP_FOEHU - Lec 03 - Sampling of Continuous Time SignalsDSP_FOEHU - Lec 03 - Sampling of Continuous Time Signals
DSP_FOEHU - Lec 03 - Sampling of Continuous Time Signals
 
A Simple Communication System Design Lab #3 with MATLAB Simulink
A Simple Communication System Design Lab #3 with MATLAB SimulinkA Simple Communication System Design Lab #3 with MATLAB Simulink
A Simple Communication System Design Lab #3 with MATLAB Simulink
 
DSP_2018_FOEHU - Lec 08 - The Discrete Fourier Transform
DSP_2018_FOEHU - Lec 08 - The Discrete Fourier TransformDSP_2018_FOEHU - Lec 08 - The Discrete Fourier Transform
DSP_2018_FOEHU - Lec 08 - The Discrete Fourier Transform
 

Similar to Multirate sim

Dsp manual
Dsp manualDsp manual
Dsp manual
pramod naik
 
EC8553 Discrete time signal processing
EC8553 Discrete time signal processing EC8553 Discrete time signal processing
EC8553 Discrete time signal processing
ssuser2797e4
 
signal and system
signal and system signal and system
signal and system
SAURAV DAYAL SING
 
Stft vs. mfcc
Stft vs. mfccStft vs. mfcc
Stft vs. mfcc
Muhammad Rizwan
 
13486500-FFT.ppt
13486500-FFT.ppt13486500-FFT.ppt
13486500-FFT.ppt
Pratik Gohel
 
13 fourierfiltrationen
13 fourierfiltrationen13 fourierfiltrationen
13 fourierfiltrationen
hoailinhtinh
 
DIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLAB
DIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLABDIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLAB
DIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLAB
Martin Wachiye Wafula
 
Reconstruction
ReconstructionReconstruction
Reconstruction
COMSATS Abbottabad
 
Numerical methods generating polynomial
Numerical methods generating polynomialNumerical methods generating polynomial
Design of Filters PPT
Design of Filters PPTDesign of Filters PPT
Design of Filters PPT
Imtiyaz Rashed
 
Applied Digital Signal Processing 1st Edition Manolakis Solutions Manual
Applied Digital Signal Processing 1st Edition Manolakis Solutions ManualApplied Digital Signal Processing 1st Edition Manolakis Solutions Manual
Applied Digital Signal Processing 1st Edition Manolakis Solutions Manual
towojixi
 
476 293
476 293476 293
Data converter modelingの参考資料1
Data converter modelingの参考資料1Data converter modelingの参考資料1
Data converter modelingの参考資料1
Tsuyoshi Horigome
 
Frequency Response with MATLAB Examples.pdf
Frequency Response with MATLAB Examples.pdfFrequency Response with MATLAB Examples.pdf
Frequency Response with MATLAB Examples.pdf
Sunil Manjani
 
Matlab kod taslağı
Matlab kod taslağıMatlab kod taslağı
Matlab kod taslağı
Merve Cvdr
 
Module1_dsffffffffffffffffffffgggpa.pptx
Module1_dsffffffffffffffffffffgggpa.pptxModule1_dsffffffffffffffffffffgggpa.pptx
Module1_dsffffffffffffffffffffgggpa.pptx
realme6igamerr
 
Matlab fair-record-model
Matlab fair-record-modelMatlab fair-record-model
Matlab fair-record-model
ajaydev1111
 
Matlab Homework Help
Matlab Homework HelpMatlab Homework Help
Matlab Homework Help
Matlab Homework Help
 
igorFreire_UCI_real-time-dsp_reports
igorFreire_UCI_real-time-dsp_reportsigorFreire_UCI_real-time-dsp_reports
igorFreire_UCI_real-time-dsp_reports
Igor Freire
 
Design and Implementation of Low Ripple Low Power Digital Phase-Locked Loop
Design and Implementation of Low Ripple Low Power Digital Phase-Locked LoopDesign and Implementation of Low Ripple Low Power Digital Phase-Locked Loop
Design and Implementation of Low Ripple Low Power Digital Phase-Locked Loop
CSCJournals
 

Similar to Multirate sim (20)

Dsp manual
Dsp manualDsp manual
Dsp manual
 
EC8553 Discrete time signal processing
EC8553 Discrete time signal processing EC8553 Discrete time signal processing
EC8553 Discrete time signal processing
 
signal and system
signal and system signal and system
signal and system
 
Stft vs. mfcc
Stft vs. mfccStft vs. mfcc
Stft vs. mfcc
 
13486500-FFT.ppt
13486500-FFT.ppt13486500-FFT.ppt
13486500-FFT.ppt
 
13 fourierfiltrationen
13 fourierfiltrationen13 fourierfiltrationen
13 fourierfiltrationen
 
DIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLAB
DIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLABDIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLAB
DIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLAB
 
Reconstruction
ReconstructionReconstruction
Reconstruction
 
Numerical methods generating polynomial
Numerical methods generating polynomialNumerical methods generating polynomial
Numerical methods generating polynomial
 
Design of Filters PPT
Design of Filters PPTDesign of Filters PPT
Design of Filters PPT
 
Applied Digital Signal Processing 1st Edition Manolakis Solutions Manual
Applied Digital Signal Processing 1st Edition Manolakis Solutions ManualApplied Digital Signal Processing 1st Edition Manolakis Solutions Manual
Applied Digital Signal Processing 1st Edition Manolakis Solutions Manual
 
476 293
476 293476 293
476 293
 
Data converter modelingの参考資料1
Data converter modelingの参考資料1Data converter modelingの参考資料1
Data converter modelingの参考資料1
 
Frequency Response with MATLAB Examples.pdf
Frequency Response with MATLAB Examples.pdfFrequency Response with MATLAB Examples.pdf
Frequency Response with MATLAB Examples.pdf
 
Matlab kod taslağı
Matlab kod taslağıMatlab kod taslağı
Matlab kod taslağı
 
Module1_dsffffffffffffffffffffgggpa.pptx
Module1_dsffffffffffffffffffffgggpa.pptxModule1_dsffffffffffffffffffffgggpa.pptx
Module1_dsffffffffffffffffffffgggpa.pptx
 
Matlab fair-record-model
Matlab fair-record-modelMatlab fair-record-model
Matlab fair-record-model
 
Matlab Homework Help
Matlab Homework HelpMatlab Homework Help
Matlab Homework Help
 
igorFreire_UCI_real-time-dsp_reports
igorFreire_UCI_real-time-dsp_reportsigorFreire_UCI_real-time-dsp_reports
igorFreire_UCI_real-time-dsp_reports
 
Design and Implementation of Low Ripple Low Power Digital Phase-Locked Loop
Design and Implementation of Low Ripple Low Power Digital Phase-Locked LoopDesign and Implementation of Low Ripple Low Power Digital Phase-Locked Loop
Design and Implementation of Low Ripple Low Power Digital Phase-Locked Loop
 

Recently uploaded

Transformers design and coooling methods
Transformers design and coooling methodsTransformers design and coooling methods
Transformers design and coooling methods
Roger Rozario
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
Hematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood CountHematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood Count
shahdabdulbaset
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
ecqow
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
amsjournal
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
JamalHussainArman
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
Las Vegas Warehouse
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
mamamaam477
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
zubairahmad848137
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
NazakatAliKhoso2
 
NATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENT
NATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENTNATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENT
NATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENT
Addu25809
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

Transformers design and coooling methods
Transformers design and coooling methodsTransformers design and coooling methods
Transformers design and coooling methods
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
Hematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood CountHematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood Count
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
 
NATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENT
NATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENTNATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENT
NATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENT
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 

Multirate sim

  • 1. Introduction 1 Multirate Sampling Simulation Using MATLAB’s Signal Processing Toolbox Introduction This technical note explains how you can very easily use the command line functions available in the MATLAB signal processing toolbox, to simulate simple multirate DSP systems. The focus here is to be able to view in the frequency domain what is happening at each stage of a system involving upsamplers, downsamplers, and lowpass filters. All computations will be performed using MATLAB and the signal processing toolbox. These same building blocks are available in Simulink via the DSP blockset. The DSP blockset allows better visualization of the overall sys- tem, but is not available in the ECE general computing laboratory or on most personal systems. A DSP block set example will be included here just so one can see the possibilities with the addi- tional MATLAB tools. Command Line Building Blocks To be able to visualize the spectra in a multirate system we need the basic building blocks of • Bandlimited signal generation; here we create a signal with a triangle shaped spectrum using sinc() • Integer upsampling and downsampling operations; here we use the signal processing tool- box functions upsample() and downsample() • Lowpass filtering for antialiasing and interpolation; here we use fir1() • If we don’t care to examine the spectra between the antialiasing lowpass filter and the deci- mator or between the upsampler and interpolation filter, we can use combination functions such as decimate(), interpolate(), and resample() Signal Generation In a theoretical discussion of sampling theory it is common place to represent the signal of interest as having a triangular shaped Fourier spectrum. Another common signal type is one or more dis- crete-time sinusoids. We know that (1) where ωcnsin πn ----------------- ω 2ωc ---------     ∏↔ F x W 2⁄W 2⁄– 1x W -----     ∏ = W
  • 2. ECE 5650/4650 Simulation with MATLAB Command Line Building Blocks 2 A triangle can be obtained in the frequency domain by noting that (2) The periodic convolution on the right-side of (2) yields where is the spectral bandwidth (single-sided or lowpass) in normalized frequency units. It then follows that for a unit height spectrum we have the transform pair (3) where Using the sinc( ) function in MATLAB, which is defined as (4) we can write (3) as (5) Creating a triangular spectrum signal in MATLAB just requires delaying the signal in samples so that both tails can be represented in a causal simulation, e.g., >> n = 0:1024; >> x = 1/4*sinc(1/4*(n-512)).^2; % set peak of signal to center of interval >> f = -1:1/512:1; % create a custom frequency axis for spectral plotting >> X = freqz(x,1,2*pi*f); %Compute the Fourier transform of x >> plot(f,abs(X)) >> print -tiff -depsc multi1.eps ωcn 2⁄( )sin πn ----------------------------- 2 1 2π ------ ω θ– ωc -------------     θ ωc ------     ∏∏ θd π– π ∫↔ F ω ωcω– c ωc 2π ------ fc= fc 2π ωc ------ ωcn 2⁄( )sin πn -----------------------------     2 Λ ω ωc ------    ↔ F x WW– 1 Λ x W -----     = sinc x( ) πxsin πx --------------≡ fc sinc fcn( )[ ] 2 Λ ω 2πfc ----------    ↔ F
  • 3. ECE 5650/4650 Simulation with MATLAB Command Line Building Blocks 3 Consider a couple of more examples: >> n = 0:1024; >> x125 = 1/8*sinc(1/8*(n-512)).^2; >> x5 = 1/2*sinc(1/2*(n-512)).^2; >> f = -1:1/512:1; >> X125 = freqz(x125,1,2*pi*f); >> X5 = freqz(x5,1,2*pi*f); >> subplot(211) >> plot(f,abs(X125)) >> subplot(212) >> plot(f,abs(X5)) >> print -tiff -depsc multi2.eps Upsample and Downsample With a means to generate a signal having bandlimited spectra in place, we can move on to the upsampling and downsampling operations. The signal processing toolbox has dedicated functions for doing this operation, although they are actually quite easy to write yourself. >> help downsample −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1 Normalized Frequency ω 2π ------ X e jω ( ) fc 0.25 or ωc π 2 ---= = −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 0 0.5 1 −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 0 0.5 1 Normalized Frequency ω 2π ------ X e jω ( ) X e jω ( ) ωc π 4 ---= ωc π=
  • 4. ECE 5650/4650 Simulation with MATLAB Command Line Building Blocks 4 DOWNSAMPLE Downsample input signal. DOWNSAMPLE(X,N) downsamples input signal X by keeping every N-th sample starting with the first. If X is a matrix, the downsampling is done along the columns of X. DOWNSAMPLE(X,N,PHASE) specifies an optional sample offset. PHASE must be an integer in the range [0, N-1]. See also UPSAMPLE, UPFIRDN, INTERP, DECIMATE, RESAMPLE. >> help upsample UPSAMPLE Upsample input signal. UPSAMPLE(X,N) upsamples input signal X by inserting N-1 zeros between input samples. X may be a vector or a signal matrix (one signal per column). UPSAMPLE(X,N,PHASE) specifies an optional sample offset. PHASE must be an integer in the range [0, N-1]. See also DOWNSAMPLE, UPFIRDN, INTERP, DECIMATE, RESAMPLE. These functions will be used in examples that follow. Filtering To implement a simple yet effective lowpass filter to prevent aliasing in a downsampler and inter- polation in an upsampler, we can use the function fir1() which designs linear phase FIR filters using a windowed sinc function. >> help fir1 FIR1 FIR filter design using the window method. B = FIR1(N,Wn) designs an N'th order lowpass FIR digital filter and returns the filter coefficients in length N+1 vector B. The cut-off frequency Wn must be between 0 < Wn < 1.0, with 1.0 corresponding to half the sample rate. The filter B is real and has linear phase. The normalized gain of the filter at Wn is -6 dB. More help beyond this, but this is the basic LPF design interface The filter design functions use half sample rate normalized frequencies: ω f′ π 2π 10 Input on f′ axis π M⁄ 1 M⁄ To get this, enter this
  • 5. ECE 5650/4650 Simulation with MATLAB System Simulation 5 To design a lowpass filter FIR filter having 128 coefficients and a cutoff frequency of , we simply type >> h = fir1(128-1,1/3); % Input cutoff as 2*fc, where fc = wc/(2pi) >> freqz(h,1,512,1) >> print -tiff -depsc multi3.eps System Simulation To keep things simple we will consider just simple decimator and interpolator systems. A Simple Decimation Example In the above system we will consider the pure decimator and the decimator with lowpass prefilter- ing. Two different values of M will be considered. As a first example we pass directly into an decimator with a signal having ( ). >> n = 0:1024; ωc π 3⁄= 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 −6000 −4000 −2000 0 Frequency (Hz) Phase(degrees) 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 −80 −60 −40 −20 0 Frequency (Hz) Magnitude(dB) Mx n[ ] y n[ ] Lowpass ωc π M -----= ω ωNω– N 1X e jω ( ) Bypass LPF M 2= ωN π 2⁄= fN 1 4⁄=
  • 6. ECE 5650/4650 Simulation with MATLAB System Simulation 6 >> x = 1/4*sinc(1/4*(n-512)).^2; >> y = downsample(x,2); >> f = -1:1/512:1; >> X = freqz(x,1,2*pi*f); >> Y = freqz(y,1,2*pi*f); >> plot(f,abs(X)) >> subplot(211) >> plot(f,abs(X)) >> subplot(212) >> plot(f,abs(Y)) >> print -tiff -depsc multi4.eps • The results are exactly as we would expect Now, use the same signal except with . First without the prefilter, and then include it to avoid aliasing. >> n = 0:1024; >> x = 1/4*sinc(1/4*(n-512)).^2; >> xf = filter(h,1,x); >> yf = downsample(xf,3); >> ynf = downsample(x,3); >> X = freqz(x,1,2*pi*f); >> Xf = freqz(xf,1,2*pi*f); >> Yf = freqz(yf,1,2*pi*f); >> Ynf = freqz(ynf,1,2*pi*f); >> subplot(411) −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 0 0.5 1 −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 Normalized Frequency ω 2π ------ X e jω ( ) Y e jω ( ) L 2 Decimation, No Prefilter= No aliasing problems M 3=
  • 7. ECE 5650/4650 Simulation with MATLAB System Simulation 7 >> plot(f,abs(X)) >> subplot(412) >> plot(f,abs(Ynf)) >> subplot(413) >> plot(f,abs(Xf)) >> subplot(414) >> plot(f,abs(Yf)) >> print -tiff -depsc multi5.eps A Simple Interpolation System In the above system we will consider the pure upsampler and the upsampler followed by a low- pass interpolation filter. Let and the signal have ( ). >> n = 0:1024; −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 0 0.5 1 −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 0 0.5 1 −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 Normalized Frequency ω 2π ------ X e jω ( ) Yf e jω ( ) Xf e jω ( ) Ynf e jω ( ) Aliasing Aliasing Unfiltered Input Filtered Input Down by 3 w/o Filter Output Down by 3 with Filter OutputShould be 0 but filter is not ideal Lowpass ωc π 3 ---=3 yr n[ ]x n[ ] yu n[ ] ω ωNω– N 1X e jω ( ) L 3= ωN π 2⁄= fN 1 4⁄=
  • 8. ECE 5650/4650 Simulation with MATLAB A DSP Blockset Example 8 >> x = 1/4*sinc(1/4*(n-512)).^2; >> y = upsample(x,3); >> X = freqz(x,1,2*pi*f); >> Y = freqz(y,1,2*pi*f); >> h = fir1(128-1, 1/3); >> yf = filter(h,1,y); >> Yf = freqz(yf,1,2*pi*f); >> subplot(311) >> plot(f,abs(X)) >> subplot(312) >> plot(f,abs(Y)) >> subplot(313) >> plot(f,abs(Yf)) >> print -tiff -depsc multi6.eps A DSP Blockset Example What can be accomplished at the MATLAB command line using just the signal processing tool- box, can be enhanced significantly by adding Simulink and the DSP blockset. Simulink is a block diagram based simulation environment that sits on top of MATLAB. The DSP blockset augments Simulink with a DSP specific block library and requires that the signal processing toolbox be present. −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 0 0.5 1 −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 0 0.5 1 −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 0 0.5 1 Normalized Frequency ω 2π ------ X e jω ( ) Yf e jω ( ) Y e jω ( ) Images removed by lowpass filter Input Spectrum Upsampled by 3 Input Interp. Upsample Output
  • 9. ECE 5650/4650 Simulation with MATLAB A DSP Blockset Example 9 As a simple example consider Text problem 4.15. The results are not shown here as they are in the solutions to problem 4.15. A sinusoidal input can be connected (the plot currently off to the side) or a signal vector from the MATLAB workspace can be used as the input. As shown above the input from the workspace is a triangular spectrum signal. The upsampler and downsampler blocks works just like the command line functions. The lowpass filter block has been designed using a GUI filter design tool (FDA tool), but ultimately uses coefficients similar to those obtained from MATLAB’s command line filter design tools. The To Workspace blocks allow the signals to be exported to the MATLAB workspace for futher manipulation. FDATool wc = Pi/8 LPF 3 Upsample simout2 To Workspace2 simout1 To Workspace1 simout To Workspace Sine Wave simin From Workspace 3 Downsample Simulation block diagram for text problem 4.15