0% found this document useful (0 votes)
46 views7 pages

W&M Lab No-1

This document provides solutions to questions about MATLAB and Simulink. It begins with an introduction to MATLAB, Simulink, and the Communications Toolbox. It then provides code and output for 4 questions: 1) Using loops and branches to plot a function, 2) Using vectorization for the same plot, 3) Calculating RMS average, and 4) Describing the functions of common Simulink blocks like signal generators, clocks, and pulse generators. It concludes by designing a Simulink model of a multiplier with a square wave input.

Uploaded by

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

W&M Lab No-1

This document provides solutions to questions about MATLAB and Simulink. It begins with an introduction to MATLAB, Simulink, and the Communications Toolbox. It then provides code and output for 4 questions: 1) Using loops and branches to plot a function, 2) Using vectorization for the same plot, 3) Calculating RMS average, and 4) Describing the functions of common Simulink blocks like signal generators, clocks, and pulse generators. It concludes by designing a Simulink model of a multiplier with a square wave input.

Uploaded by

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

IN THE NAME OF ALLAH(S.W.T) WHO IS MOST MERCIFUL & BENEFICAL.

WIRELESS & MOBILE COMMUNICATION LAB NO-1


INTRODUCTION TO MATLAB, SIMULINK, AND COMMUNICATION TOOLBOX

SOLUTION:
QUESTION NO-1:
PART:A
BY USING LOOPS & BRANCHES:
SOLUTION:
MATLAB CODE:
clc;
clear all;

t = -9:1:9;
for n = 1:1:9
y(n) = 3*t(n)^2+5;
end
for n = 10:1:19
y(n) = -3*t(n)^2+5;
end
plot(t,y)

OUTPUT:
PART :B
BY USING VECTORIZATION:
MATLAB CODE:
clc;
clear all;

t = -9:0.5:9;
m = (t>=0).*((-3*t.^2)+5);
n = (t<0).*((3*t.^2)+5);
y = m+n;
plot(y)

OUTPUT:
QUESTION NO-2:
SOLUTION:
MATLAB CODE:

OUTPUT:
QUESTION NO-3:
RMS AVERAGE:
SOLUTION:
MATLAB CODE:
clc;
clear all;

x = [10,5,2,5];
n = length(x);
rms = ((sum(x.^2))/n)^(1/2);
rms;

OUTPUT:
QUESTION NO-4:
SIMULINK MODEL BLOCKS & ITS FUNCTION:
PART A:
SOLUTION:
I. SIGNAL GENERATOR BLOCK:
The SIGNAL GENERATOR BLOCK can produce one of four different waveforms:
 SINE
 SQUARE
 SAWTOOTH
 RANDOM
You can express signal parameters in hertz or radians per second by using its default parameter
values.

II. DIGITAL CLOCK:


 To view the simulation sample time at a specified sampling interval using the DIGITAL
CLOCK BLOCK.

III. STEP BLOCK:


The STEP BLOCK provides a step between two definable levels at a specified time. If the
simulation time is less than the Step time parameter value, the block's output is the Initial
value parameter value. For simulation time greater than or equal to the Step time, the output is
the Final value parameter value.

IV. UNIFORM RANDOM NUMBER BLOCK:


The Uniform Random Number block generates uniformly distributed random numbers over an
interval that you specify. To generate normally distributed random numbers, use the RANDOM
NUMBER BLOCK. Both blocks use the Normal (Gaussian) random number generator.

V. PULSE GENERATOR BLOCK:


The PULSE GENERATOR block generates square wave pulses at regular intervals. The
block waveform parameters, Amplitude, Pulse Width, Period, and Phase delay, determine the
shape of the output waveform.
VI. SINE WAVE FUNCTION BLOCK:
The SINE WAVE BLOCK outputs a SINUSOIDAL WAVEFORM. The block can operate in
time-based or sample-based mode.

PART B:
DESIGN A MULTIPLIER WITH A SQUARE-WAVE INPUT:

SOLUTION:

SIMULINK MODEL:

OUTPUT:

You might also like