Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Modify the user-defined function GaussPivot in Program 4-2 (Example 4-3) such that in each step of the elimination the pivot row is switched with the
Modify the user-defined function GaussPivot in Program 4-2 (Example 4-3) such that in each step of the elimination the pivot row is switched with the row that has a pivot element with the largest absolute numerical value. For the function name and arguments use x = GaussPivotLarge (a,b), where a is the matrix of coefficients, b is the right-hand-side column of constants, and x is the solution.
(a) Use the GaussPivotLarge function to solve the system of linear equations in Eq. (4.17).
(b) Use the GaussPivotLarge function to solve the system:
Example 4-3: MATLAB user-defined function for solving a system of equations using Gauss elimination with pivoting. Write a user-defined MATLAB function for solving a system of linear equations [a][x] = [b] using the Gauss elimination method with piv- oting. Name the function x GaussPivot (a,b), where a is the matrix of coefficients, b is the right-hand-side column vector of con- stants, and x is a column vector of the solution. Use the function to determine the forces in the loaded eight-member truss that is shown in the figure (same as in Fig. 4-2) SOLUTION 4000 N The forces in the eight truss members are determined from the set of eight equations, Eqs. (4.2). The equations are derived by drawing free body diagrams of pins A, B, C, and D and applying equations of equilibrium. The equations are rewritten here in a matrix form (intentionally, the equations are written in an order that requires piv- oting 20m 0 0.9231 0 0 0 0 1-0.3846 0 0 0 0 1690 3625 0 0 0 0 1 0 0.8575 0 BC 1 0 0.7809 0 0 0 (4.17) 0 -0.3846 -0.7809 0 -1 0.38460 0 FCD 0 0.9231 0.6247 0 0 -0.9231 0 0F 0 0 0.6247 -1 0 0 0 0 DE 0 1 0 0-0.5145 -1 The function GaussPivot is created by modifying the function Gauss listed in the solution of Example 42 Program 4-2: User-defined function. Gauss elimination with pivoting function x = Gaus s Pivot (a, b) % The function solves a system of linear equations ax b using the Gauss % elimination method with pivoting. Input variables: % a The matrix of coefficients. % b Right-hand-side column vector of constants Output variable: % x A column vector with the s lution ab= [a,b]; [R, c] = size (ab); for j = 1:R-1 % Pivoting section starts if ab (j , j ) = = 0 Check if the pivot element is zeroStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started