Question: Function LUfac_solver.m is provided here: function [x] = LUfac_solver(LU,b,piv) % % function [x] = LUfac_solver(lu,b) % % This program employs the LU factorization to solve

 Function LUfac_solver.m is provided here: function [x] = LUfac_solver(LU,b,piv) % %

Function LUfac_solver.m is provided here:

function [x] = LUfac_solver(LU,b,piv)

%

% function [x] = LUfac_solver(lu,b)

%

% This program employs the LU factorization to solve the linear system Ax=b.

%

% Input

% LU: lu matrix from GEpivot_new function

% b: right side column vector (ordered corresponding to original vector

% sent to GEpivot_new)

% piv: vector indicating the pivoting (row interchanges that took place

% during GE

%

% Output

% x: solution vector

%

% Written by Steve Margulis for CEE 103. This assumes the LU matrix is that

% provided by the GEpivot_new.m function.

% First rearrange b vector to reflect pivoting operations that occurred

% in GE pivot function

b=b(piv);

[m,n] = size(LU);

% Next construct L and U matrices from lu matrix. Note that L*U should

% equal the original matrix A with pivoting. This is why "b" is pivoted

% above to match.

U=triu(LU); % Grab upper triangular part of LU matrix

% Grab lower triangular part of LU matrix

%--Note need to replace diag. with ones

L=tril(LU);

for i=1:n

L(i,i)=1;

end

% STEP 1:

% Solve the lower triangular system using L

z=zeros(n,1);

z(1)=b(1)/L(1,1);

for i=2:1:n % Note implied matrix summation in L*z term below

z(i)=(b(i)-L(i,1:i-1)*z(1:i-1))/L(i,i);

end

% STEP 2:

% Solve the upper triangular system using U

x = zeros(n,1);

x(n) = z(n)/U(n,n);

for i = n-1:-1:1 % Note implied matrix summation in U*x term below

x(i)=(z(i)-U(i,i+1:n)*x(i+1:n))/U(i,i);

end

Problem #2 provided for reference:

function [x] = LUfac_solver(lu,b) % % This program employs the LU factorization

Problem #3: The same crane discussed in Problem #2 is loaded differently, ie P-Ps-500 P2 = P,--500 a) Write a MATLAB script using the lower and upper triangular matrices constructed via the Gaussian elimination in Problem #2, with the function LUfac solver to use the LU factorization method to solve the problem for these new loads. Your code should not modify LUfac_solver in any way (you should just pass inputs to it and receive outputs from it) b) Does the maximum displacement location change? Is it a vertical or horizontal displacement? (Turn in your MATLAB code for this problem. Make sure to build your code so that the TAs can evaluate it by clicking on "run" only. Remember to copy all your files into a folder, zip that folder, and upload it to CCLE.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!