Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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:

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago