Practical-8 AIM:-To Perform LU Decomposition On A Given Matrix in MATLAB
Practical-8 AIM:-To Perform LU Decomposition On A Given Matrix in MATLAB
PRACTICAL- 8
Compute the LU factorization of a matrix and examine the resulting factors. LU factorization is a
way of decomposing a matrix A into an upper triangular matrix U, a lower triangular matrix L, and
a permutation matrix P such that PA=LU. These matrices describe the steps needed to perform
Gaussian elimination on the matrix until it is in reduced row echelon form. The L matrix contains
all of the multipliers, and the permutation matrix P accounts for row interchanges.
1. [L,U] = lu(A) factorizes the full or sparse matrix A into an upper triangular matrix U and a
permuted lower triangular matrix L such that A = P*L
2. example
[L,U,P] = lu(A) also returns a permutation matrix P such that A = P'*L*U. With this syntax, L is
unit lower triangular and U is upper triangular.
example
example
[___] = lu(S,thresh) specifies thresholds for the pivoting strategy employed by lu using any of the
previous output argument combinations. Depending on the number of output arguments specified,
the default value and requirements for the thresh input are different. See the thresh argument
description for details.
example
Enrollment no:190303105559
Faculty Of Engineering & Technology
Subject Name: IT Workshop 2
Subject Code: 203105258
B. Tech 2nd Year 4th Semester
INPUT
A = [10 -7 0
-3 2 6
5 -1 5];
[L,U] = lu(A)
INPU
T
[L,U,P] = lu(A)
OUTPUT
Enrollment no:190303105559
Faculty Of Engineering & Technology
Subject Name: IT Workshop 2
Subject Code: 203105258
B. Tech 2nd Year 4th Semester
INPU
T
P'*L*U
OUTPUT
INPUT
:
A = magic(5)
b = 65*ones(5,1);
x = A\b
OUTPUT:
Enrollment no:190303105559
Faculty Of Engineering & Technology
Subject Name: IT Workshop 2
Subject Code: 203105258
B. Tech 2nd Year 4th Semester
INPUT
[L,U,P] = lu(A)
OUTPUT
INPUT
y = L\(P*b);
x = U\y
OUTPUT
Enrollment no:190303105559
Faculty Of Engineering & Technology
Subject Name: IT Workshop 2
Subject Code: 203105258
B. Tech 2nd Year 4th Semester
PRACTICAL -9
Aim : To Perform singular value decomposition on a given matrix in MATLAB
Singular Value Decomposition
Enrollment no:190303105559
Faculty Of Engineering & Technology
Subject Name: IT Workshop 2
Subject Code: 203105258
B. Tech 2nd Year 4th Semester
svd returns two unitary matrices, U and V, the columns of which are singular vectors. It also
returns a diagonal matrix, S, containing singular values on its diagonal. The elements of all three
matrices are floating-point numbers. The accuracy of computations is determined by the current
setting of digits.
Create the n-by-n matrix A with elements defined by A(i,j) = 1/(i - j + 1/2). The
most obvious way of generating this matrix is
INPUT
n = 3;
for i = 1:n
for j = 1:n
A(i,j) = sym(1/(i-j+1/2));
end
end
For n = 3, the matrix is
A
A=
[ 2, -2, -2/3]
[ 2/3, 2, -2]
[ 2/5, 2/3, 2]
Compute the singular values of this matrix. If you use svd directly, it will return exact symbolic
result. For this matrix, the result is very long. If you prefer a shorter numeric result, convert the
elements of A to floating-point numbers using vpa. Then use svd to compute singular values of
this matrix using variable-precision arithmetic:
S = svd(vpa(A))
S=
3.1387302525015353960741348953506
3.0107425975027462353291981598225
1.6053456783345441725883965978052
Now, compute the singular values and singular vectors of A:
[U,S,V] = svd(A)
U=
[ 0.53254331027335338470683368360204, 0.76576895948802052989304092179952,...
0.36054891952096214791189887728353]
[ -0.82525689650849463222502853672224, 0.37514965283965451993171338605042,...
0.42215375485651489522488031917364]
Enrollment no:190303105559
Faculty Of Engineering & Technology
Subject Name: IT Workshop 2
Subject Code: 203105258
B. Tech 2nd Year 4th Semester
[ 0.18801243961043281839917114171742, -0.52236064041897439447429784257224,...
0.83173955292075192178421874331406]
S=
[ 3.1387302525015353960741348953506, 0,...
0]
[ 0, 3.0107425975027462353291981598225,...
0]
[ 0, 0,...
1.6053456783345441725883965978052]
V=
[ 0.18801243961043281839917114171742, 0.52236064041897439447429784257224,...
0.83173955292075192178421874331406]
[ -0.82525689650849463222502853672224, -0.37514965283965451993171338605042,...
0.42215375485651489522488031917364]
[ 0.53254331027335338470683368360204, -0.76576895948802052989304092179952,...
0.36054891952096214791189887728353]
Enrollment no:190303105559
Faculty Of Engineering & Technology
Subject Name: IT Workshop 2
Subject Code: 203105258
B. Tech 2nd Year 4th Semester
PRACTICAL :10
APPLICATION OF MATLAB
Enrollment no:190303105559
Faculty Of Engineering & Technology
Subject Name: IT Workshop 2
Subject Code: 203105258
B. Tech 2nd Year 4th Semester
In this case study, scientists in Australia are using video footage to estimate the wildlife
population of waterbirds.
Case study: Advancing Wildlife Research: The Development of a Solution to Process Video
Footage of Waterbirds
https://www.mathworks.com/content/dam/mathworks/mathworks-dot-
com/solutions/aerospace-defense/files/2017/conf-au/advancing-wildlife-research-the-
development-of-a-solution-to-process-video-footage-of-waterbirds.pdf
Video applications present common but difficult challenges that require flexible analysis
and processing functionality. Using MATLAB® and Simulink® products, you can develop
solutions to common video processing challenges such as video stabilization, video
mosaicking, target detection, and tracking.MATLAB® provides tools and algorithms that
let you view, analyze, read, and write videos. Video processing can be useful in applications
like:
Enrollment no:190303105559
Faculty Of Engineering & Technology
Subject Name: IT Workshop 2
Subject Code: 203105258
B. Tech 2nd Year 4th Semester
Enrollment no:190303105559
Faculty Of Engineering & Technology
Subject Name: IT Workshop 2
Subject Code: 203105258
B. Tech 2nd Year 4th Semester
Enrollment no:190303105559
Faculty Of Engineering & Technology
Subject Name: IT Workshop 2
Subject Code: 203105258
B. Tech 2nd Year 4th Semester
Video processing can be very simple, as in the example using edge detection, or
significantly more complex, such as tracking algorithms that must account for an object’s
location in previous frames.
Step 4. Writing the Video
After processing, you can write each frame of a video back to a file. You can create a video
file with the function:
>> vid_w = VideoWriter('newfile.avi');
>> open(vid_w)
Enrollment no:190303105559
Faculty Of Engineering & Technology
Subject Name: IT Workshop 2
Subject Code: 203105258
B. Tech 2nd Year 4th Semester
end
close(myVideo)
Enrollment no:190303105559
Faculty Of Engineering & Technology
Subject Name: IT Workshop 2
Subject Code: 203105258
B. Tech 2nd Year 4th Semester
Enrollment no:190303105559