% To solve the system, we first define a matrix... % coefficients of the system

advertisement
% To solve the system, we first define a matrix A containing the
% coefficients of the system
A = [2.5, -1, 3, 1.5, 02; 3, 4, -2, 2.5, 01; -4, 3, 1, -6, 2;
2, 3, 1, -2.5, 4; 1, 2, 5, -3, 4];
% We can only solve this system if A is invertible, so we need to check
% that det(A) is nonzero (in your homework, you do not need to include
% this in your solution - you can just check in the command window, and
% continue if A is invertible)
detA = det(A)
% Next, we define a column vector B containing the right hand sides of each
% of the equations.
B = [57.1; 27.6; -81.2; -22.2; -12.2];
% Finally, we find our solution, which is just the inverse of A times B
% (note that here we are using the \ operator instead of inv(A) for better
% accuracy).
A\B
detA =
354.2500
ans =
-11.1490
-4.3238
1.7965
25.3174
18.6416
Published with MATLAB® R2014a
1
Download