Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Introduction
Simulink (Simulation and Link) is an extension of MATLAB by Mathworks Inc. It works
with MATLAB to offer modeling, simulating, and analyzing of dynamical systems under a
graphical user interface (GUI) environment.
Getting Started
Execute MATLAB and type “simulink” in the command window, or click the icon in the
tool bar.
Library
Example 1:
Simulate the equation A(t)sin(2πfc t), for 0 < t < 10, unit: second
where A(t) = t for t > 0, fc = 50Hz
a) Source 1:
(i) Descriptions:
Sine Wave: Output a sine wave where the sine type determines the computational
technique used. The parameters in the two types are related through:
Samples per period = 2*pi / (Frequency * Sample time)
Number of offset samples = Phase * Samples per period / (2*pi)
Use the sample-based sine type if numerical problems due to running for large
times (e.g. overflow in absolute time) occur.
Output waveform:
(b) Source 2: function A(t) = t
Use the function “ramp”
Where to get it?
Simulink Sources Ramp
The output signal will be
Output(t)=initial_output + slope x (t-start_time)
Parameters:
Slope of the function = 1
Start time = 0 sec
Initial output = 0
(i)
Multiplication: can use either “
dot product”or “
product” .
Where to get it?
Simulink Math Operations product / dot product
Differences: “product” allow more than 2 inputs
Connect the source blocks and the block “ dot product” :
Drag the “dot product” to the model
Move the mouse near the output port of the source,
and mouse becomes “+”
Click at the output port and release until the mouse
is near the input port
If the blocks are not connected, release until the mouse
is near the input port
Right click
Advanced Examples
Example 1: Integrator;
(a) Calculate the average value of the signal within specified period.
(b) Set the parameter value for each blocks refer the output graph.
2 sin(pi t)
Sample and hold, zero-order hold: convert continuous time signal into discrete time. Set
the parameter value for each blocks refer the output graph and explain briefly different
output between scope and scope 1
Single after sample and hold (Rise edge triggering) 2 sin (pi/4 0.25n).[Discrete sine wave, sampling period=0.25second]
Example 3;
Design the 3 Bit PCM System above with the parameter given by instructor.
The Scalar Quantizer Encoder block maps each input value to a quantization region by
comparing the input value to the quantizer boundary points defined in the Boundary
points parameter. The block outputs then zero-based index of the associated region.
You can select how you want to enter the Boundary points using the Source of quantizer
parameters. When you select Specify via dialog, type the boundary points into the block
parameters dialog box. When you select Input port, port B appears on the block. The
block uses the input to port B as the Boundary points parameter. Use the Boundary
points parameter to specify the boundary points for your quantizer. These values are
used to break up the set of input numbers into regions. Each region is specified by an
index number. Let N be the number of quantization regions. When the codebook is
defined as [c1 c2 c3 ... cN], and the Boundary points parameter is defined as [p0 p1 p2
p3 ... pN], then p0<c1<p1<c2 ... p(N-1)<cN<pN for a regular quantizer. When your
quantizer is bounded, from the Partitioning list, select Bounded. You need to specify N+1
boundary points, or [p0 p1 p2 p3 ... pN]. When your quantizer is unbounded, from the
Partitioning list, select Unbounded. You need to specify N-1 boundary points, or[p1 p2
p3 ... p(N-1)]; the block sets p0 equal to -inf and pN equal to inf. The block uses the
Partitioning parameter to interpret the boundary points you enter. For instance, to
create a bounded quantizer, from the Partitioning list, select Bounded and enter the
following boundary points:[0 0.5 3.7 5.8 6.0 11] The block assigns any input values
between 0 and 0.5 to index 0, input values between 0.5 and 3.7 to index 1, and so on.
The block assigns any values that are less than 0 to index 0, the lowest index value. The
block assigns any values that are greater than 11 to index 4, the highest index value. To
create an unbounded quantizer, from the Partitioning list, select Unbounded and enter
the following boundary points:[0 0.5 3.7 5.8 6.0 11] The block assigns any input values
between 0 and 0.5 to index 1, input values between 0.5 and 3.7 to index 2, and so on.
The block assigns any input values less than 0 to index 0 and any values greater than
11 to index 6. (For details go to MATLAB HELP)
The Integer to Bit Converter block maps each integer in the input vector to a group of
bits in the output vector. If M is the Number of bits per integer parameter, then the input
integers must be between 0 and 2M-1. The block maps each integer to a group of M bits,
using the first bit as the most significant bit. As a result, the output vector length is M
times the input vector length. (See MATLAB Help for details)
The Bit to Integer Converter block maps groups of bits in the input vector to integers in
the output vector. If M is the Number of bits per integer parameter, then the block maps
each group of M bits to an integer between 0 and 2M-1. As a result, the output vector
length is 1/M times the input vector length.If the input is sample-based input, then it must
be a vector whose length equals the Number of bits per integer parameter. If the input is
frame-based, then it must be a column vector whose length is an integer multiple of
number of bits per integer. The block interprets the first bit in each group as the most
significant bit. (See MATLAB Help for details)
Output result ;
The signals we use in the real world, such as our voices, are called "analog" signals. To
process these signals in computers, we need to convert the signals to "digital" form.
While an analog signal is continuous in both time and amplitude, a digital signal is
discrete in both time and amplitude. To convert a signal from continuous time to discrete
time, a process called sampling is used. The value of the signal is measured at certain
intervals in time. Each measurement is referred to as a sample.
Design the sampling prosess above with the parameter given by instructor. Set the
parameter value for each blocks and explain briefly the output waveform scope and
scope 1.
Exercise 2
Exercise 3