Sei sulla pagina 1di 15

Mobile Communication Lab

Lab 05

To Perform Signal Companding in Simulink

Prepared by Engr Ali M Durrani


1
(CECOS University) ali@cecos.edu.pk
Companding a Signal
• In certain applications, such as speech processing, it is
common to use a logarithm computation, called a
compressor, before quantizing.

• The inverse operation of a compressor is called an


expander.

• The combination of a compressor and expander is called a


compander.

• Communication blockset supports two kinds of


companders: µ-law and A-law companders

Prepared by Engr Ali M Durrani


2
(CECOS University) ali@cecos.edu.pk
Example 5a
• Quantizes an exponential signal in two ways
1) Computation using the Sampled Quantizer Encode block
with a partition consisting of length-one intervals.
2) Using the Mu-Law Compressor block.
and compare the resulting mean square distortions.

Prepared by Engr Ali M Durrani


3
(CECOS University) ali@cecos.edu.pk
Creating the Signal in Workspace
• To create the signal in the MATLAB workspace,
execute these commands:

>> sig= -4:.1:4;


>> sig= exp(sig'); % Exponential signal to quantize

Prepared by Engr Ali M Durrani


4
(CECOS University) ali@cecos.edu.pk
Building the Model
• To start building the model, follow these steps:

• Type commlib at the MATLAB prompt.


This opens the Communications Blockset main library.

• Type dsplib at the MATLAB prompt.


This opens the DSP Blockset main library.

• Type simulink3 at the MATLAB prompt.


This opens the Main Simulink Library.

• From the library's File menu, select New and then select Model.
Prepared by Engr Ali M Durrani
5
(CECOS University) ali@cecos.edu.pk
• Signal From Workspace

Set Signal to sig

Prepared by Engr Ali M Durrani


6
(CECOS University) ali@cecos.edu.pk
• Quantizing Encoder
- Set Quantization partition to 0:floor(max(sig))
- Set Quantization codebook to 0:ceil(max(sig))

Prepared by Engr Ali M Durrani


7
(CECOS University) ali@cecos.edu.pk
• Mu-Law Compressor
- Set Peak signal magnitude to max(sig)

Prepared by Engr Ali M Durrani


8
(CECOS University) ali@cecos.edu.pk
• Mu-Law Expander
• - Set Peak signal magnitude to ceil(max(sig))

Prepared by Engr Ali M Durrani


9
(CECOS University) ali@cecos.edu.pk
• Terminator
• To Workspace (2 copies)
• Scope

Prepared by Engr Ali M Durrani


10
(CECOS University) ali@cecos.edu.pk
• Two copies of To Workspace, in the Simulink
Sinks library
- Set Variable names to
nocompander and withcompander

- Set Save format to Array in each of the two


copies of this block.

Prepared by Engr Ali M Durrani


11
(CECOS University) ali@cecos.edu.pk
• Mux
• Demux

Prepared by Engr Ali M Durrani


12
(CECOS University) ali@cecos.edu.pk
Running Simulation
• Connect the blocks as shown
• Set Stop time to 80

Prepared by Engr Ali M Durrani


13
(CECOS University) ali@cecos.edu.pk
Analyzing the Results
• Run the model, then execute these commands:

• This output shows that the distortion is smaller for the second
scheme.

Prepared by Engr Ali M Durrani


14
(CECOS University) ali@cecos.edu.pk
Lab Task 5a
• Quantizes an exponential signal in two ways
1) Using the Mu-Law Compressor block.
2) Using A-Law Compressor block.
and compare the resulting mean square
distortions
• Determine which technique has low distortion

Prepared by Engr Ali M Durrani


15
(CECOS University) ali@cecos.edu.pk

Potrebbero piacerti anche