Академический Документы
Профессиональный Документы
Культура Документы
Linear algebraic equations can be solved ‘by hand’ using pencil and
paper, by calculator, or with software such as MATLAB. The problems
arise when we deal with more than 2 variables in the said equation.
Then, MATLAB is a software that can give us the solution.
a21x + a22 y = b2
Example:
>> [x,y]=solve('a11*x+a12*y=b1, a21*x+a22*y=b2')
x=
-(-a22*b1+b2*a12)/(a11*a22-a12*a21)
y=
(a11*b2-b1*a21)/(a11*a22-a12*a21)
>> 'a11'*x+'a12'*y
ans =
-a11*(-a22*b1+b2*a12)/(a11*a22-a12*a21)+a12*(a11*b2-b1*a21)/(a11*a22-
a12*a21)
>> simplify(ans)
ans =
b1
Example:
>> A=[1 2 3; 4 5 6; 7 8 9]
A=
1 2 3
4 5 6
7 8 9
A=
1.0000 2.0000 3.0000
0 -0.8571 -1.7143
4.0000 5.0000 6.0000
8
Example:
>> A=[1 2 3; 4 5 6; 7 8 9]
A=
1 2 3
9
4 5 6
7 8 9
>> rref(A)
ans =
1 0 -1
0 1 2
0 0 0
10
Example:
A_B =
7 1 10 -1
3 8 5 2
2 5 5 -2
ans =
1.0000 0 0 2.5000
0 1.0000 0 0.5000
12
0 0 1.0000 -1.9000
⎛ 1...0...0 ⎞⎛ x ⎞ ⎛ 2.5 ⎞
⎜⎜ 0...1...0 ⎟⎜
⎟⎜
y ⎟ = ⎜ 0.5 ⎟
⎟ ⎜ −1.9 ⎟
⎝ 0...0...1 ⎠⎝ ⎠ ⎝ ⎠
z
X = A_B(:,size (A_B,2))
Example:
>> A=[1 2 1; 0 1 2; -1 3 2] %enter matrix A
A=
1 2 1
0 1 2
14
-1 3 2
1.7729( λ2 )
-1.1642( λ3 )
>> lambda=ans;
>> v1=null(A1)
v1 =
0.6509
0.4871
0.5824
-0.3059
-0.1182
>> eig(A)
ans =
3.3914
1.7729
-1.1642
The eigenvectors which are corresponds to the above eigen values also
can obtained using function eig.
19
>> [V,D]=eig(A)
V=
0.6509 -0.9447 -0.2766
0.4871 -0.3059 0.6522
0.5824 -0.1182 -0.7058
D=
3.3914 0 0
0 1.7729 0
20
0 0 -1.1642
21