1
4.32 The axial force F i in each of the 13-member pin-
connected truss, shown in the figure, can be calculated 1800 N 600 N 800 N 600 N
10
by solving the following system of 13 equations: 6
2
F 2 + 0.707F 1 = 0 , F 3 – 0.707F 1 – 2000 = 0
1 5 9 13
8m
0.7071F 1 + F 4 + 6229 = 0 , – F 2 + 0.659F 5 + F 6 = 0 4 8 12
2000 N
– F 4 – 0.753F 5 – 600 = 0 , – F 3 – 0.659F 5 + F 7 = 0 3 7 11
0.753F 5 + F 8 = 0 , – F 6 + 0.659F 9 + F 10 = 0 8m 7m 7m 8m
– F 8 – 0.753F 9 – 800 = 0 , – F 7 – 0.659F 9 + F 11 = 0
0.753F 9 + F 12 – 2429 = 0 , – F 10 + 0.707F 13 = 0
– F 12 – 0.7071F 13 – 600 = 0
(a) Solve the system of equations using the user-defined function GaussPivotLarge developed in
Problem 4.21.
(b) Solve the system of equations using Gauss–Seidel iteration. Does the solution converge for a starting
(guess) vector whose elements are all zero?
(c) Solve the system of equations using MATLAB’s left division operation.
Solution
The listing of the user-defined function GaussPivotLarge is:
function x = GaussPivotLarge(a,b)
% The function solve a system of linear equations ax=b using the Gauss
% elimination method with pivoting. In each step the pivot element has the
% largest absolute numerical value.
% Input variables:
% a The matrix of coefficients.
% b A column vector of constants.
% Output variable:
% x A colum vector with the solution.
ab = [a,b];
[R, C] = size(ab);
for j = 1:R-1
% Pivoting section starts.
Excerpts from this work may be reproduced by instructors for distribution on a not-for-profit basis
for testing or instructional purposes only to students enrolled in courses for which the textbook
has been adopted. Any other reproduction or translation of this work beyond that permitted by
Sections 107 or 108 of the 1976 United States Copyright Act without the permission of the
copyright owner is unlawful.
2
pvtemp=ab(j,j);
kpvt=j;
% Looking for the row with the largest pivot element.
for k=j+1:R
if ab(k,j)~=0 & abs(ab(k,j)) > abs(pvtemp)
pvtemp=ab(k,j);
kpvt=k;
end
end
% If a row with a larger pivot element exists, switch the rows.
if kpvt~=j
abTemp=ab(j,:);
ab(j,:)=ab(kpvt,:);
ab(kpvt,:)=abTemp;
end
% Pivoting section ends
for i = j+1:R
ab(i,j:C) = ab(i,j:C)-ab(i,j)/ab(j,j)*ab(j,j:C);
end
end
x = zeros(R,1);
x(R) = ab(R,C)/ab(R,R);
for i = R-1:-1:1
x(i)=(ab(i,C)-ab(i,i+1:R)*x(i+1:R))/ab(i,i);
end
(a, c) The following program (script file) uses the user-defined GaussPivotLarge function to solve the
system of linear equations that is given in the problem statement.
clear, clc
A=[0.707 1 0 0 0 0 0 0 0 0 0 0 0
-0.707 0 1 0 0 0 0 0 0 0 0 0 0
0.7071 0 0 1 0 0 0 0 0 0 0 0 0
0 -1 0 0 0.659 0 1 0 0 0 0 0 0
Excerpts from this work may be reproduced by instructors for distribution on a not-for-profit basis
for testing or instructional purposes only to students enrolled in courses for which the textbook
has been adopted. Any other reproduction or translation of this work beyond that permitted by
Sections 107 or 108 of the 1976 United States Copyright Act without the permission of the
copyright owner is unlawful.
3
0 0 0 -1 -0.753 0 0 0 0 0 0 0 0
0 0 -1 0 -0.659 0 1 0 0 0 0 0 0
0 0 0 0 0.753 0 0 1 0 0 0 0 0
0 0 0 0 0 -1 0 0 0.659 1 0 0 0
0 0 0 0 0 0 0 -1 -0.753 0 0 0 0
0 0 0 0 0 0 -1 0 -0.659 0 1 0 0
0 0 0 0 0 0 0 0 0.753 0 0 1 0
0 0 0 0 0 0 0 0 0 -1 0 0 0.707
0 0 0 0 0 0 0 0 0 0 0 -1 -0.7071];
b=[0; 2000; -6229; 0; 600; 0; 0; 0; 800; 0; 2429; 0; 600];
format short e
disp('Part (a)')
c = GaussPivotLarge(A,b)
disp('Part (c)')
c=A\b
When the program is executed, the following result is displayed in the Command Window.
Part (a)
c =
-4.4699e+03
3.1602e+03
-1.1602e+03
-3.0683e+03
3.2780e+03
9.9613e+01
1.0000e+03
-2.4683e+03
2.2156e+03
-1.3605e+03
2.4601e+03
7.6066e+02
-1.9243e+03
Excerpts from this work may be reproduced by instructors for distribution on a not-for-profit basis
for testing or instructional purposes only to students enrolled in courses for which the textbook
has been adopted. Any other reproduction or translation of this work beyond that permitted by
Sections 107 or 108 of the 1976 United States Copyright Act without the permission of the
copyright owner is unlawful.
4
Part (c)
c =
-4.4699e+03
3.1602e+03
-1.1602e+03
-3.0683e+03
3.2780e+03
9.9613e+01
1.0000e+03
-2.4683e+03
2.2156e+03
-1.3605e+03
2.4601e+03
7.6066e+02
-1.9243e+03
(b) A solution of the system with the Gauss–Seidel iteration method does not converge.
Excerpts from this work may be reproduced by instructors for distribution on a not-for-profit basis
for testing or instructional purposes only to students enrolled in courses for which the textbook
has been adopted. Any other reproduction or translation of this work beyond that permitted by
Sections 107 or 108 of the 1976 United States Copyright Act without the permission of the
copyright owner is unlawful.