0% found this document useful (0 votes)
277 views28 pages

Lab 02 To Generate Random Bits and Random Noise Signals in Simulink

This document discusses generating random signals and random noise in Simulink using blocks from the Communications Blockset. It describes the sample time, seed, and signal attribute parameters for random source blocks. It provides examples of using the Rayleigh Noise Generator and Bernoulli Random Binary Generator blocks to produce various random output signals. The lab tasks involve changing parameters of the Rayleigh Noise Generator block to achieve specific output signal types.

Uploaded by

Arshad Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
277 views28 pages

Lab 02 To Generate Random Bits and Random Noise Signals in Simulink

This document discusses generating random signals and random noise in Simulink using blocks from the Communications Blockset. It describes the sample time, seed, and signal attribute parameters for random source blocks. It provides examples of using the Rayleigh Noise Generator and Bernoulli Random Binary Generator blocks to produce various random output signals. The lab tasks involve changing parameters of the Rayleigh Noise Generator block to achieve specific output signal types.

Uploaded by

Arshad Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Mobile Communication Lab

Lab 02

To Generate random bits and random


noise signals in Simulink

Prepared by Engr Ali M Durrani


1
(CECOS University) [email protected]
Communications Sources
• Every communication system contains one or more
sources.

• You can find sources in Simulink’s Sources library, in the


DSP Blockset’s DSP Sources library, and in the
Communication Blockset’s Comm Sources library.

• You can open the Comm Sources library by double-


clicking on its icon in the main Communications
Blockset library (commlib), or by typing
commsource2 at the MATLAB prompt.
Prepared by Engr Ali M Durrani
2
(CECOS University) [email protected]
Source Features of the Blockset

• Blocks in this library can:

• Generate random or pseudorandom signals

• Generate nonrandom signals by reading from


a file or by simulating a voltage-controlled
oscillator (VCO).

Prepared by Engr Ali M Durrani


3
(CECOS University) [email protected]
Random Signals
• Random signals are useful for simulating noise, errors, or
signal sources.

• Besides using built-in Simulink blocks such as the Random


Number block, you can also use blocks in the Comm
Sources library of the Communications Blockset to
generate:

• Random bits
• Random integers
• Pseudorandom integers
• Random real numbers

Prepared by Engr Ali M Durrani


4
(CECOS University) [email protected]
• This lab discusses the

• Sample time parameter


• Seed parameter
• Signal attribute parameters

that are common to many random source blocks,


and then discusses each category of random
source.
Prepared by Engr Ali M Durrani
5
(CECOS University) [email protected]
Sample Time Parameter for Random
Sources
• Each of the random source blocks requires you to set a
Sample time parameter in the block mask.

• If you configure the block to produce a


sample-based signal, then this parameter is the time
interval between successive updates of the signal.

• If you configure the block to produce a frame-based


matrix signal, then the Sample time parameter is the
time interval between successive rows of the
frame-based matrix.
Prepared by Engr Ali M Durrani
6
(CECOS University) [email protected]
• If you use a Simulink Probe block to query the
period of a frame-based output from a
random source block in the Comm Sources
library.

• Then note that the Probe block reports the


period of the entire frame,not the period of
each sample in a given channel of the frame.

Prepared by Engr Ali M Durrani


7
(CECOS University) [email protected]
• The equation below relates the quantities
involved for a single-channel signal.

A seconds/frame = (B seconds/sample)*
(S samples/frame)

where:
• A is the number shown in the Probe block after
the Tf notation.
• B is the random source block’s Sample time
parameter.
• S is the random source block’s Samples per frame
parameter.
Prepared by Engr Ali M Durrani
8
(CECOS University) [email protected]
Seed Parameter for Random Sources
• Each of the random source blocks requires you to set a seed in the
block mask.

• This is the initial seed that the random number generator uses
when forming its sequence of numbers.

• If you choose a constant seed, then the block produces the same
noise sequence each time you start the simulation.

• The sequence will be different from that produced with a different


constant seed.

• If you want the noise to be different each time you start the
simulation, then you can use a varying seed such as cputime.
Prepared by Engr Ali M Durrani
9
(CECOS University) [email protected]
Signal Attribute Parameters for
Random Sources
• In most random source blocks, the output can
be a frame-based matrix, a sample-based row
or column vector, or a sample-based one-
dimensional array

• The table in next few slides indicates how to


set certain block parameters depending on
the kind of signal you want to generate

Prepared by Engr Ali M Durrani


10
(CECOS University) [email protected]
Prepared by Engr Ali M Durrani
11
(CECOS University) [email protected]
Prepared by Engr Ali M Durrani
12
(CECOS University) [email protected]
• The Frame-based outputs and Interpret vector
parameters as 1-D check boxes are mutually
exclusive.

• Because frame-based signals and one-


dimensional signals are mutually exclusive.

• The Samples per frame parameter field is active


only if the Frame-based outputs check box is
checked.

Prepared by Engr Ali M Durrani


13
(CECOS University) [email protected]
Example 2a :-
Generation of Sampled based one dimensional
signal
• To start building the model, follow these steps:

• Type commlib at the MATLAB prompt.


This opens the Communications Blockset main library.

• To open the main Simulink library, type simulink3 at the


MATLAB prompt

• From the library's File menu, select New and then select
Model.
Prepared by Engr Ali M Durrani
14
(CECOS University) [email protected]
• Rayleigh Noise Generator

– Set Initial seed to [12 34]

Prepared by Engr Ali M Durrani


15
(CECOS University) [email protected]
• Set the stop time to inf and run the simulation

• In the case of the Rayleigh Noise Generator block, the first two
block parameters (Sigma and Initial seed) determine the number of
channels in the output

• The number of elements in the Initial seed parameter becomes the


number of columns in a frame-based output or the number of
elements in a sample-based vector output.

• Also, the shape (row or column) of the Initial seed parameter


becomes the shape of a sample-based two-dimensional output
signal. Prepared by Engr Ali M Durrani
16
(CECOS University) [email protected]
Lab Task 2a
• Change the parameters of the Rayleigh Noise
Generator to obtain the following outputs

Prepared by Engr Ali M Durrani


17
(CECOS University) [email protected]
Lab Task 2b
• Change the parameters of the Rayleigh Noise
Generator to obtain the following outputs

Prepared by Engr Ali M Durrani


18
(CECOS University) [email protected]
Random Bits
• The Bernoulli Random Binary Generator
generate random bits

• As a result, the Bernoulli Random Binary


Generator block is suitable for representing
sources.

Prepared by Engr Ali M Durrani


19
(CECOS University) [email protected]
Bernoulli Random Binary Generator
• The Bernoulli Random Binary Generator block
generates random binary numbers using a
Bernoulli distribution.

• The Probability of a zero parameter specifies


p, and can be any real number between zero
and one.

Prepared by Engr Ali M Durrani


20
(CECOS University) [email protected]
Bernoulli Random Binary Generator
• The output signal can be a frame-based matrix, a sample-based row
or column vector, or a sample-based one-dimensional array.

• These attributes are controlled by the Frame-based outputs,


Samples per frame and Interpret vector parameters as 1-D
parameters.

• The number of elements in the Initial seed and Probability of a zero


parameters becomes the number of columns in a frame-based
output or the number of elements in a sample-based vector output.

• Also, the shape (row or column) of the Initial seed and Probability
of a zero parameters becomes the shape of a sample-based two-
dimensional output signal.

Prepared by Engr Ali M Durrani


21
(CECOS University) [email protected]
Example 2b:-
Generate a random binary number
with 40% probability of zeros
• In the Communications Blockset main library,
double-click on the Comm Sources icon. This
opens the Comm Sources library.

• In the Comm Sources library, find the icon for


the Bernoulli Random Binary Generator block.
Drag it into the model window.

Prepared by Engr Ali M Durrani


22
(CECOS University) [email protected]
• Probability of zeros [0.4 0.4 0.4 0.4]
• Initial Seed [1 1 1 1]
• Uncheck the frame based data box

Prepared by Engr Ali M Durrani


23
(CECOS University) [email protected]
• Set the stop time to inf and run the simulation

Prepared by Engr Ali M Durrani


24
(CECOS University) [email protected]
Lab Task 2c
• Generate a random binary number with 90%
probability of 1s
• How can you observe the data generated graphically ?

Prepared by Engr Ali M Durrani


25
(CECOS University) [email protected]
Lab Task 2d
• Generate a random binary number of 8 bits
with 70% probability of zeros for even bits and
30% probability of zeros for odd bits

Prepared by Engr Ali M Durrani


26
(CECOS University) [email protected]
Random Integers
• The Random-Integer Generator and Poisson Int
Generator blocks both generate vectors
containing random nonnegative integers.

• The Random-Integer Generator block uses a


uniform distribution on a bounded range that you
specify in the block mask.

• The Poisson Int Generator block uses a Poisson


distribution to determine its output. In particular,
the output can include any nonnegative integer
Prepared by Engr Ali M Durrani
27
(CECOS University) [email protected]
Random Real Numbers
• You can use one of several blocks to generate
random real numbers, depending on what
distribution you want to use.

Prepared by Engr Ali M Durrani


28
(CECOS University) [email protected]

You might also like