Question

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.)

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:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

%from problem 2
load prob2output.mat
b=[500;-500;500;-500];
[x] = LUfac_solver(lu,b,piv)

Add a comment
Know the answer?
Add Answer to:
Function LUfac_solver.m is provided here: function [x] = LUfac_solver(LU,b,piv) % % function [x] = LUfac_solver(lu,b) %...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1 point) Find the LU factorization of 4 -5 -20 23 That is, write A LU where L is a lower triangular matrix with ones on...

    1 point) Find the LU factorization of 4 -5 -20 23 That is, write A LU where L is a lower triangular matrix with ones on the diagonal, and U is an upper triangular matrix A= 1 point) Find the LU factorization of 4 -5 -20 23 That is, write A LU where L is a lower triangular matrix with ones on the diagonal, and U is an upper triangular matrix A=

  • In this exercise you will work with LU factorization of an matrix A. Theory: Any matrix A can be ...

    In this exercise you will work with LU factorization of an matrix A. Theory: Any matrix A can be reduced to an echelon form by using only row replacement and row interchanging operations. Row interchanging is almost always necessary for a computer realization because it reduces the round off errors in calculations - this strategy in computer calculation is called partial pivoting, which refers to selecting for a pivot the largest by absolute value entry in a column. The MATLAB...

  • (1 point) Find the LU factorization of That is, write A = LU where L is...

    (1 point) Find the LU factorization of That is, write A = LU where L is a lower triangular matrix with ones on the diagonal, and U is an upper triangular matrix.

  • Using MATLAB, develop an M-file to determine LU factorization of a square matrix with partial pivoting....

    Using MATLAB, develop an M-file to determine LU factorization of a square matrix with partial pivoting. That is, develop a function called mylu that is passed the square matrix [A] and returns the triangular matrices [L] and [U] and the permutation P. You are not to use MATLAB built-in function lu in your codes. Test your function by using it to solve a system of equations listed below in part 3. Confirm that your function is working properly by verifying...

  • 3. Given the matrix [ -1 2 -1] A= 3 2 1 10 10 1 Following...

    3. Given the matrix [ -1 2 -1] A= 3 2 1 10 10 1 Following steps (a)(b) to obtain the LU decomposition of the matrix A with partial piv- oting (a) Apply the Gaussian elimination method with partial pivoting to obtain an upper trian- gular matrix U. Record the corresponding permutation matrix for each pivoting step, and the numbers lik used to eliminate the zeros in column k. (b) Based on (a), express the matrices P, L and U...

  • (1 point) Find the LU factorization of -g 3 -3 A = 4 LU where L...

    (1 point) Find the LU factorization of -g 3 -3 A = 4 LU where L is a lower triangular matrix with ones on the diagonal, and U is an upper triangular matrix. That is, write A A =

  • 3 (The UL factorization.) Show how to compute the factorization A = UL where U is...

    3 (The UL factorization.) Show how to compute the factorization A = UL where U is upper triangular with ls along the diagonal and L is lower triangular. Show how this relates to a way of solving Ax = b by transforming the system into an equivalent system with a lower triangular matrix. (In other words, show that what we did for the LU factorization also works for a UL factorization.) Note: For the purposes of this exercise you may...

  • (911 (1) (a) Recall that a square matrix A has an LU decomposition if we can...

    (911 (1) (a) Recall that a square matrix A has an LU decomposition if we can write it as the product A = LU of a lower triangular matrix and an upper triangular matrix. Show that the matrix 0 1 21 A= 3 4 5 (6 7 9] does not have an LU decomposition 0 0 Uji U12 U13 O 1 2 Il 21 l22 0 0 U22 U23 = 3 4 5 (131 132 133 0 0 U33 6...

  • 06.Matrix Factorization: Problem 11 Previous Problem Problem List Next Problem (1 point) Find the LU factorization...

    06.Matrix Factorization: Problem 11 Previous Problem Problem List Next Problem (1 point) Find the LU factorization of -E 2 2 A 4 That is, write A LU where L is a lower trianqular matrix with ones on the diagonal, and U is an upper triangular matrix A Note: You can eam partial credit on this problem Preview My Answers Submit Answers You have attempted this problem 0 times

  • 1. (All students!) For matrices with special properties, it is possible to create special version...

    1. (All students!) For matrices with special properties, it is possible to create special versions of Gauss elimination. Suppose matrix A (nxn) is symmetric (which means that A-A). Suppose also that A is positive definite; this means that the scalar = xTAx is always 20 for every vector x , and J-0 only if x = 0 In this case it can be shown that the usual Gauss elimination process, which effectively creates the factorization A LU, can be simplified...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT