Creat three .m files and name them LUDe- comp.m , TriDiag.m , and JacobiMeth.m o
ID: 3682471 • Letter: C
Question
Creat three .m files and name them LUDe- comp.m, TriDiag.m, and JacobiMeth.m or CramerRule.m
Project description. Given system of linear equations in matrix form where A [aij]nxn - coefficient matrix = - non-zero vector of free terms Cilnxi vector of unknowns Create three MATLAB functions to solve system in (1) using LU Decomposition method. tri-diagonal algorithm (assume the matrix you are given is in tri-diagonal form already), and one of the two - Jacobi method or Cramer's rule. All your functions take matrix A and vector b as input and output the solution of system in 1) as vector x along with a string variable which informs if any errors occured while executing your function(s). Note that all your programs should handle the situation if input matrix A is singular and system has no (or infinitely many) solutions. In this case assign value of zero-vector to x and leave the proper message in the output string-variable. Neither of your functions should display splay anything to screen. Also, make sure that your LU decomposition routine can handle this scenario (use pivoting) A=1200 If vour program for any reason gives "red ink", meaning doesn't run due to compilation or any other errors, you will receive zero credit for that particular part of project.Explanation / Answer
It generates regularly spaced elements and represents an entire row or column.
Using a colon in addressing Arrays:
An Array is a list of numbers or expressions arranged in horizontal rows and vertical columns.
When an array has only one row or column, it is called a vector. An array with m rows and n columns is called a matrix of size mxn.
A colon can be used to address a range of elements in a vector or a matrix.
For a vector v(:) refer to all the elements of vector V. V(m:n)refers to elements m through n of the vector.
For a matrix
A(:,n) refer to the elements in all rows of column n of the matrix A.
A(n,:) refer to the elements in all the columns of row n of the matrix A.
A(:,m:n)refers to the elements in all the rows between columns m and n of the matrix A.
A(m:n,:) refers to the elements in all the elements between rows m and n of the matrix A.
A(m:n,p:q) refers to the elements in rows m through n and columns p through q.
Ex:1 . create a matrix A with 5 rows and 6 columns and create another column vector B from the elements in all the rows of column 3 in matrix A.
>> A=[1 3 5 7 9 11;2 4 6 8 10 12;3 6 9 12 15 18;4 8 12 16 20 24;5 10 15 20 25 30]
A = 1 3 5 7 9 11
2 4 6 8 10 12
3 6 9 12 15 18
4 8 12 16 20 24
5 10 15 20 25 30
>> A(3,2)% it shows that 3rd row 2nd column.
ans = 6
>> B=A(:,3) % it shows that all rows in third column.
B = 5
6
9
12
15
>> C=A(2,:) % it shows that all columns in second row.
C = 2 4 6 8 10 12
>> A(:,2:3) % it shows that all rows in 2nd to 3rd columns
ans =
3 5
4 6
6 9
8 12
10 15
>> A(2:3,:)% it shows that all columns with 2nd to third row.
ans =
2 4 6 8 10 12
3 6 9 12 15 18
1.1.12 Parentheses — ( )
Parentheses are used mostly for indexing into elements of an array or for specifying arguments passed to a called function. Parenthesis also control the order of operations, and can group a vector visually (such as x = (1:10)) without calling a concatenation function.
Array Indexing
When parentheses appear to the right of a variable name, they are indices into the array stored in that variable:
Function Input Arguments
When parentheses follow a function name in a function declaration or call, the enclosed list contains input arguments used by the function:
It encloses function arguments and array indices; overrides precedence.
Example : >> a=(1:1:10)
a =
1 2 3 4 5 6 7 8 9 10
1.1.13 Square Brackets — [ ]
Square brackets are used in array construction and concatenation, and also in declaring and capturing values returned by a function.
Array Constructor
To construct a matrix or array, enclose all elements of the array in square brackets:
Concatenation
To combine two or more arrays into a new array through concatenation, enclose all array elements in square brackets:
Function Declarations and Calls
When declaring or calling a function that returns more than one output, enclose each return value that you need in square brackets:
It enclosures array elements.
The square brackets operator constructs two-dimensional matrices only, (including 0-by-0, 1-by-1, and 1-by-n matrices).
Example :
>> [1 2 3 4]
ans = 1 2 3 4
>> [1;2;3]
ans =
1
2
3
>> [1 2 3; 4 3 2; 2 5 6]
ans =
1 2 3
4 3 2
2 5 6