Question

Write Matlab script for computing inverse of a matrix using LU decomposition/factorization. You are not allowed...

Write Matlab script for computing inverse of a matrix using LU decomposition/factorization. You are not allowed to use the Matlab’s lu function.

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

`Hey,

Note: If you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

clc%clears screen
clear all%clears history
close all%closes all files
format long
A=[1,2,3;4,5,6;2,7,5];
[L,U]=ludecomp(A)
function[L,U]=ludecomp(A)
[m n]=size(A);
if (m ~= n )
disp ( 'LR2 error: Matrix must be square' );
return;
end;
% Part 2 : Decomposition of matrix into L and U
L=zeros(m,m);
U=zeros(m,m);
for i=1:m
% Finding L
for k=1:i-1
L(i,k)=A(i,k);
for j=1:k-1
L(i,k)= L(i,k)-L(i,j)*U(j,k);
end
L(i,k) = L(i,k)/U(k,k);
end
% Finding U
for k=i:m
U(i,k) = A(i,k);
for j=1:i-1
U(i,k)= U(i,k)-L(i,j)*U(j,k);
end
end
end
for i=1:m
L(i,i)=1;
end
end

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Write Matlab script for computing inverse of a matrix using LU decomposition/factorization. You are not allowed...
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
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