Matlab Experiment
Matlab Experiment
CASTILLO
Review on MatLab
Laboratory Experiment No. __
Performance Objectives
INTRODUCTION
Matlab is an interactive package for numerical analysis, matrix manipulation, control systems design,
linear system analysis and digital signal processing. The most recent application of matlab is for digital
filters, their design and application, using “toolboxes” specifically the DSP toolbox.
TO OPEN MATLAB
Go to start menu, programs and look for the matlab application and open it or double-click the matlab
icon on the desktop to access the matlab software. The matlab command window will appear. This is
where you enter commands at the >>prompt and where the matlab displays the numerical outputs.
TO EXIT MATLAB:
Type Quit on the command prompt or select Exit matlab from the File menu.
ONLINE HELP
Help is always available every session of matlab. Matlab is case sensitive, meaning all commands and
variables must be entered in lower case. There are several ways to get help:
Objective A and B
L = 5mH; % inductance
C = 0.1μF %capacitance
Formula:
Fr = 7117.6 Hz
Formula:
RT = 58.8235 ohms
5x2 + 3x –5 = 0
a=5 b=3 c = -5
Formula:
X1 = -1.344
X2 = 0.744
4. Solve for x
Formula:
X = 16
Formula:
Θh = 43.10 deg
Objective C and D
1. Define the matrices given below. Write the command that you used to define those matrices.
A=
1 2 3
4 5 6
7 8 9
Command: B= 1:15;
B=
1 2 3 4 5 6 7 8 9 10 11 12 13
14 15
Command: v = [2 4 6 8 10];
C = diag(v);
C=
2 0 0 0 0
0 4 0 0 0
0 0 6 0 0
0 0 0 8 0
0 0 0 0 10
D=
1 3 5 7 9
11 13 15 17 19
21 23 25 27 29
Command: E = [1:0.5:3;2:0.6:4.4;5:0.1:5.4];
3
MACY J. CASTILLO
E=
1.0000 1.5000 2.0000 2.5000 3.0000
2.0000 2.6000 3.2000 3.8000 4.4000
5.0000 5.1000 5.2000 5.3000 5.4000
2. Now, create the matrices given using commands that will extract elements of reference matrices.
Take note: you must not define those matrices, the elements must be extracted using the lecture
discussed above. Write the command that you used on the space given below.
F=
1.0000 1.5000 2.0000
2.5000 3.0000
21.0000
23.0000 25.0000 27.0000
29.0000
0 0
0
0 10.0000
b. Command: G = [A([4 7]) A(4) D([10 13]) ; A([5 8]) D([4 11 14]); A([6
9 5]) D([12 15])];
G=
2 3 2 7 9
5 6 3 17 19
8 9 5 27 29
H =
Columns 1 through 6
Columns 7 through 10
4
MACY J. CASTILLO
10.0000 20.0000 30.0000 40.0000
d. Define a table of sine values from sin 0 to sin 10 using matrices. Fill up the table below
and write the commands you used.
X 1 2 3 4 5 6 7 8 9 10
Sin x
0.8415 0.9093 0.1411 -0.7568 -0.9589 -0.2794 0.657 0.9894 0.4121 -0.54
40
Command: X = [1:10];
Command: Y= sin(X);
Procedure:
1. Define all the matrices given below
A=
1 -3 -7
2 -5 0
-1 9 -4
B=
-1 2 3
2 -4 6
3 6 -9
5
MACY J. CASTILLO
C=
4 -7 9
2 -4 7
9 0 -2
D=
0 -1 -2
-3 8 -4
-1 9 -3
E=
1 8 3
1 9 3
1 9 3
2. Solve the following equations and give observations on your result. Write also the command you
used to solve the equation. Compare the MATLAB result from the computational result.
a. Z1 = 3A
Command: Z1=3*A
z =
3 -9 -21
6 -15 0
-3 27 -12
Command:
z2=c*c
z2 =
6
MACY J. CASTILLO
83 0 5
63 2 4
54 -63 85
z2=c.*c
z2 =
16 49 81
4 16 49
81 0 4
Observation: For the first command, we used a multiplication operator. In the second
command, we used an element wise operator which multiplies each element by C.
Command: Z3 = A.*E
z3 =
1 -24 -21
2 -45 0
-1 81 -12
Command: Z4 = (a*b*c)+(2*b*e*d)^3-(4*a*c);
Z4 =
7
MACY J. CASTILLO
e.
Z5 =
1.0e+15 *