Professional Documents
Culture Documents
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:
1
Objective A and B
L = 5mH; % inductance
C = 0.1µF %capacitance
Formula:
1
f r=
2 π √ LC
Fr = 7.1176e+03 Hz
5x2 + 3x –5 = 0
a=5 b=3 c = -5
Formula:
−b ± √ b −4 ac
2
x=
2a
X1 = 0.7440
X2 = -1.3440
2
4. Solve for x
Formula:
√ 2 √16 √ x=2
3 3
X = 16
Formula:
−1 λ
ϴh=2 cos (1−0.1398 )
Nd
ϴh = 43.0992°
Objective C and D
1. Define the matrices given below. Write the command that you used to define those matrices.
Command: A = [1 2 3; 4 5 6; 7 8 9]
A=
1 2 3
4 5 6
7 8 9
Command: B = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]
B=
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Command: 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]
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
3
D=
1 3 5 7 9
11 13 15 17 19
21 23 25 27 29
Command: E = [1 1.5 2 2.5 3; 2 2.5 3.2 3.8 4.4; 5 5.1 5.2 5.3 5.4]
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
G=
2 3 2 7 9
5 6 3 17 19
8 9 5 27 29
G=
10.0000 9.5000 9.0000 8.5000 8.0000 7.5000 7.0000 6.5000 6.0000 5.5000
7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000
-50.0000 -40.0000 -30.0000 -20.0000 -10.0000 0 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
4
Sin x 0.8415 0.9093 0.1411 -0.7568 -0.9589 -0.2794 0.6570 0.9894 0.4121 -0.5440
Command: Sinx = [sin(1), sin(2), sin(3), sin(4), sin(5), sin(6), sin(7), sin(8), sin(9), sin(10)]
Procedures
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
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
5
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
Z1 =
6 -12 18
9 18 -27
3 -9 -21
6 -15 0
-3 27 -12
Observation:
The individual element inside matrix A is multiplied with the value of 3. Therefore 3*A
basically triples the value of each element enclosed in the matrix.
Z2 = Z2 =
83 0 -31 16 49 81
63 2 -24 4 16 49
18 -63 85 81 0 4
Observation:
C*C means that its multiplying both matrix which involves a complicated process, while C.*C
basically squares the value of each element inside the matrix since we are multiplying the
same matrix but if it were to different matrices then that would mean that each element
from the first matrix will get multiplied directly to the corresponding element on the second
matrix with respect to the individual element of each matrix.
Command: Z3 = A.*E
Z3 =
-1 -6 -21
4 20 0
-3 54 36
Observation:
The individual elements in matrix A is multiplied directly and respectively to the individual
elements of matrix B.
3
d. Z 4= ABC +( 2 BED) – 4 AC
Command: Z4 = (A*B*C)+((2*B*E*D)^3)-(4*A*C)
Z4 =
-68462092 224966048 -107772456
-64765696 212817116 -101951824
3697903 -12148293 5819111
Observation:
Since all the input matrices are 3x3 the corresponding output has also a 3x3 dimension.
Otherwise the operations involved wouldn’t be possible.
e.
Z5 =¿ ¿
Command: Z5 = (((A*C'*B*D')^4)*(A'*D*E))/(((A*B*C)+(B*E))^1/3)
Z5 =
1.0e+16 *
Observation:
The value of the individual elements inside matrix Z 5 is evidently very large due to the fact
that it is multiplied with the scalar quantity 1x10 16.
After doing the experiment, I got more familiar with the different expressions and operations that
involves matrices and arrays including basic indexing. Defining a matrix from another matrix widened my
perspective in the usage of matlab and I believe that this is only barely scratching the surface of the
software usage itself. Also, I noticed that matlab has two different types of arithmetic operations: array
operations and matrix operations. Matrix operations follow the rules of linear algebra. By contrast, array
operations execute element by element operations and support multidimensional arrays. The period
character (.) distinguishes the array operations from the matrix operations. However, since the matrix
and array operations are the same for addition and subtraction, the character pairs. + and.- are
unnecessary.