%MAT 275 MATLAB Assignment #2
%Kristi Mass
%Exercise 1
%Defining Matrices and Vectors
A=[1,4,2;2,5,8;3,6,9]
B=[1,2,3;4,5,6;7,8,9]
b=[4;23;27]
c=[4,3,2]
d=[1;2;3]
%Part A
%Performing Matrix Operations
A*B
ans =
31 38 45
78 93 108
90 108 126
B*A
ans =
14 32 45
32 77 102
50 122 159
c*B
ans =
30 39 48
A*d
ans =
15
36
42
%Part B:
%Constructing New Matrices from the Defined Matrices
C=[A,B] %New 3x6 Matrix
C =
1 4 2 1 2 3
2 5 8 4 5 6
3 6 9 7 8 9
D=[B;c] %New 4x3 Matrix
D =
1 2 3
4 5 6
7 8 9
4 3 2
%Part C
%Solve the System Ax=b Using Backslash Command
x=A\b
x =
4.0000
-1.2500
2.5000
%Part D
%Replace A(2,3) with 0