Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The aim is to start developing an R or MatLab toolkit for deaing with matrix pro

ID: 3753338 • Letter: T

Question



The aim is to start developing an R or MatLab toolkit for deaing with matrix problems. Later assignments will continue this. This part is worth 40 marks and a questions must be attempted by both MATH 4370 and MATH 7370 students. . Use R or MatLab . The result of this part of the assignment can consist of two parts: a non-mandatory companion PDF file with extended documentation of the functions produced, stating explicitly the definitions and theorems used, etc.; an R file (or multiple MatLab files) containing all the functions. The companion file is optional: if you comment your code abundantly, then it should not be required if no further mathematical developments are . The functions must be named and take arguments as prescribed here, so that a single test function can be used to verify the results for all students . Your companion file, if any, should be in PDF format Given a matrix M E Mm, each function should first ensure that the matrix has the proper size (eg be square if the result being applied involves a square matrix). The following functions should be available: . is .real.matrix(M) is true if M € M(R) . is .complex.matrix(M) is true if M e M1(C) and 31, j such that 3(my)0 . isdiagonal.natrix(M) is true if M E M(C) is a diagonal matrix . is lower triangular matrix(M) is true if M EM(C) is a lower triangular matrix. . is upper triangular matrix(M) is true if M E M(C) is an upper triangular matrix . is.triangular matrix(M) is true if M E M(C) is a triangular matrix . is hermitian matrix(M) is true if MEM(C) is a Hermitian matrix . is.skew hermitian matrix(M) is true if M EM(C) is a skew Hermitian matrix.

Explanation / Answer

function matrix=matrix_functions
matrix.is_real_matrix=@is_real_matrix;
matrix.is_complex_matrix=@is_complex_matrix;
matrix.is_diagonal_matrix=@is_diagonal_matrix;
matrix.is_lower_triangle_matrix=@is_lower_triangle_matrix;
matrix.is_upper_triangle_matrix=@is_upper_triangle_matrix;
matrix.is_triangular_matrix=@is_triangular_matrix;
matrix.is_hermitian_matrix=@is_hermitian_matrix;
matrix.is_skew_hermitian_matrix=@is_skew_hermitian_matrix;
  
end

function a=is_real_matrix(M)
if isreal(M)
disp('Yes, matrix M is real')
else
disp('No, matrix M is not real')
end
end
function b=is_complex_matrix(M)
if isreal(M)
disp('No, matrix is not complex')
else
disp('Yes, matrix is complex')
end
end
function c=is_diagonal_matrix(M)
  
d=size(M);
rows=d(1);
cols=d(2);
found=0;
found1=0;
for i=1:rows
for j=1:cols
if (i~=j && M(i, j)~=0)
found=1;
break;
end   
if (i==j && M(i, j)~=0)
found1=1;
end
end
end
if(found1==1 && found==0)
disp('Diagonal matrix')
else
disp('Not a diagonal matrix')
end
  
end
function d=is_lower_triangle_matrix(M)
d=size(M);
rows=d(1);
cols=d(2);
found=0;
for i=1:rows
for j=1:cols
if (i<j && M(i, j)~=0)
found=1;
break
end
end
end
if found==1
disp('Not an lower triangular triangle')
else
disp('Lower triangular matrix')
end
  
end
function f=is_upper_triangle_matrix(M)
d=size(M);
rows=d(1);
cols=d(2);
found=0;
for i=1:rows
for j=1:cols
if (i>j && M(i, j)~=0)
found=1;
break
end
end
end
if found==1
disp('Not an upper triangular triangle')
else
disp('Upper triangular matrix')
end
end
function g=is_triangular_matrix(M)
  
d=size(M);
rows=d(1);
cols=d(2);
  
found1=0;
for i=1:rows
for j=1:cols
if (i>j && M(i, j)~=0)
found1=1;
break
end
end
end
  
found2=0;
for i=1:rows
for j=1:cols
if (i<j && M(i, j)~=0)
found2=1;
break
end
end
end
if found1==1 || found2==1
disp('Triangular matrix')
else
disp('Not a triangular matrix')
end
end
function h=is_hermitian_matrix(M)
if M==transpose(conj(M))
disp('Hermitian Matrix')
else
disp('Not a hermitian matrix')
end
end
function s=is_skew_hermitian_matrix(M)
if M==-transpose(conj(M))
disp('Skew Hermitian Matrix')
else
disp('Not a Skew hermitian matrix')
end
end

On matlab terminal, just call,

x=function_name

x.is_hermitian_matrix(M) , to test if M is a hermitian matrix.

Code is self-explained.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote