Page 83 - MATLAB an introduction with applications
P. 83
68 ——— MATLAB: An Introduction with Applications
Example E1.18: Find the inverse of the following matrices using MATLAB:
3 2 0 − 4 2 5 − 1 2 − 5
(a) 2 − 1 7 (b) 7 − 1 6 (c) 4 3 7
5 4 9 2 3 7 7 − 6 1
Solution:
>> clear % Clears the workspace
>> A = [3 2 0; 2 –1 7; 5 4 9]; % Spaces separate matrix columns – semicolons
separate matrix rows
>> B = [–4 2 5; 7 –1 6; 2 3 7]; % Spaces separate matrix columns – semicolons
separate matrix rows
>> C = [–1 2 -5; 4 3 7; 7 –6 1]; % Spaces separate matrix columns – semicolons
separate matrix rows
>> inv(A); % Finds the inverse of the selected matrix
>> inv(B); % Finds the inverse of the selected matrix
>> inv(C) % Finds the inverse of the selected matrix
% Inverse of A
ans =
0.4805 0.2338 –0.1818
–0.2208 –0.3506 0.2727
0.1688 0.0260 0.0909
% Inverse of B
ans =
–0.1773 0.0071 0.1206
–0.2624 –0.2695 0.4184
0.1631 0.1135 0.0709
% Inverse of C
ans =
0.1667 0.1037 0.1074
0.1667 0.1259 –0.0481
–0.1667 0.0296 –0.0407
Example E1.19: Determine the eigenvalues and eigenvectors of matrix A using MATLAB
4 − 1 5 35 7
(a) A = 2 1 3 (b) A = 24 8
6 − 7 9 56 10
F:\Final Book\Sanjay\IIIrd Printout\Dt. 10-03-09