Académique Documents
Professionnel Documents
Culture Documents
Anouska Acharya
MATLAB 1
1. Arithmetic Functions
1. 3^2
ans =
2. 2\18
ans =
3. 25*4
ans =
100
4. (1/(2+3^2)) + (4/5)*(6/7)
ans =
0.7766
2. Trigonometric Functions
1. acos(30)
ans =
0.0000 + 4.0941i
2. sind(60)
ans =
0.8660
3.Logarithmic Function
1. log10(10)
ans =
2. Matrix Functions
v= [1 2 3; 4 5 6; 7 8 9]
v =
1 2 3
4 5 6
7 8 9
3. v(2)
ans =
4. v(2, 3)
ans =
5. v'
ans =
1 4 7
2 5 8
3 6 9
6. det(v)
ans =
-9.5162e-16
7. inv(v)
ans =
1.0e+16 *
8. v(:, 2)
ans =
2
5
8
9. eye(2, 3)
ans =
1 0 0
0 1 0
10. zeros(2,3)
ans =
0 0 0
0 0 0
11. ones(3,3)
ans =
1 1 1
1 1 1
1 1 1
12. rand(2, 3)
ans =
13. a= [1 2 3; 4 5 6; 7 8 9]
a =
1 2 3
4 5 6
7 8 9
b= [4 5 7; 8 6 5; 2 1 3]
b =
4 5 7
8 6 5
2 1 3
13.1. a*b
ans =
26 20 26
68 56 71
110 92 116
13.2. a.*b
ans =
4 10 21
32 30 30
14 8 27
13.3. a./b
ans =
x =
16.3334
format long
x
x =
16.333444445555557
format short
x
x =
16.3334
Question:
Solve for x, y, z
X+2y+3z= 1
3x+3y+4z= 1
2x+3y+3z=2
A= [1 2 3; 3 3 4; 2 3 3]
A =
1 2 3
3 3 4
2 3 3
b= [1;1;2]
b =
1
1
2
x= inv(A)*b
x =
-0.5000
1.5000
-0.5000