You are on page 1of 9

LAB NO-1

INTRODUCTION TO MATLAB, SIMULINK, AND COMMUNICATION TOOLBOX

SOLUTION:
QUESTION NO-1:
SOLUTION:
MATLAB CODE:
clear all;
clc;
t = -9:0.5:9;
if (t >= 0)
y= -3*(t.^2)+5;
else
y= (3*(t.^2))+5;
end
plot(t,y)

OUTPUT:
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:
clear all;
clc;
t = 0:pi/10:6*pi;
y= sin(t);
plot(t,y)

OUTPUT:
MATLAB CODE:
clear all;
clc;
t = 0:pi/10:6*pi;
y= sin(t);
plot(t,y)
%hold all
for t= -6*pi:pi/10:6*pi
if (t >= 0)
y= sin(t);
else
y= 0;
end
stem(t,y)
hold all
end

OUTPUT:
QUESTION NO-3:
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:
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.

SINE WAVE FUNCTION BLOCK:


The SINE WAVE BLOCK outputs a SINUSOIDAL WAVEFORM. The block can operate in
time-based or sample-based mode.
SOLUTION:

SIMULINK MODEL:

PULSE GENERATOR BLOCK SETTINGS:

GAIN BLOCK SETTINGS:


SIMULINK PARAMETER SETTINGS:
OUTPUT:

CONCLUSION:

You might also like