Use Octave Given a matrix M ? M mn , each function should first ensure that the...

Free

60.1K

Verified Solution

Question

Advance Math

Use Octave

Given a matrix M ? M mn , each function should first ensure thatthe matrix has the proper size (e.g., be
square if the definition involves a square matrix). Until CA4, wedo not implement proper error handling,
so for now, if the matrix is not of the proper size, the functionshould return FALSE. In this assignment,
we create functions that characterise matrix properties or types.These definitions can be found easily. For
reference, the location of some of the definitions in the Horn& Johnson book is provided. The following
functions should be made available:  
1. is_ real _matrix(M) is true if M ? M(R).
2. is _complex _matrix(M) is true if M ? M(C) and ?i,j such that=(m ij ) 6= 0.
3. is _diagonal_ matrix(M) is true if M ? M(C) is a diagonal matrix(H&J 0.9.1).
4. is_ lower _triangular_ matrix(M) is true if M ? M(C) is a lowertriangular matrix (H&J 0.9.3).
5. is _upper _triangular_ matrix(M) is true if M ? M(C) is an uppertriangular matrix (H&J 0.9.3).
6. is _triangular _matrix(M) is true if M ? M(C) is a triangularmatrix (H&J 0.9.3).
7. is _symmetric_ matrix(M) is true if M ? M(C) is a symmetricmatrix.
8. is -hermitian _matrix(M) is true if M ? M(C) is a Hermitianmatrix.
9. is_ skew _hermitian _matrix(M) is true if M ? M(C) is a skewHermitian matrix.
10. is_ normal _matrix(M) is true if M ? M(C) is a normalmatrix.
11. is _unitary_ matrix(M) is true if M ? M(C) is a unitarymatrix.
12. is_ orthogonal_ matrix(M) is true if M ? M(C) is an orthogonalmatrix.
13. is_ permutation _matrix(M) is true if M ? M(C) is a permutationmatrix (H&J 0.9.5).
14. is _reversal_ matrix(M) is true if M ? M(C) is a reversalmatrix (H&J 0.9.5).
15. is _circulant _matrix(M) is true if M ? M(C) is a circulantmatrix (H&J 0.9.6).
16. is _Toeplitz_ matrix(M) is true if M ? M(C) is a Toeplitzmatrix (H&J 0.9.7).
17. is _Hankel _matrix(M) is true if M ? M(C) is a Hankel matrix(H&J 0.9.8).
18. is _lower_ Hessenberg matrix(M) is true if M ? M(C) is a lowerHessenberg matrix (H&J 0.9.9).
19. is_ upper_Hessenberg matrix(M) is true if M ? M(C) is an upperHessenberg matrix (H&J 0.9.9).
20. is _tridiagonal_ matrix(M) is true if M ? M(C) is a tridiagonalmatrix (H&J 0.9.10).
21. is _Jacobi _matrix(M) is true if M ? M(C) is a Jacobi matrix(H&J 0.9.10).
22. is_ persymmetric_ matrix(M) is true if M ? M(C) is apersymmetric matrix (H&J 0.9.10).

Answer & Explanation Solved by verified expert
3.7 Ratings (422 Votes)

1. function is_real_matrix(M)
count=0;
for i=M
if(!isreal(i))
fprintf(" The matrix has non real entries.")
count=count+1;
endif
endfor
if(!count)
fprintf(" The matrix is real ! ")
endif
endfunction

2. function is_complex_matrix(M)
count=0;
for i=M
if(iscomplex(i))
fprintf(" The matrix has complex entries.")
count=count+1;
endif
endfor
if(!count)
fprintf(" The matrix is not complex! ")
endif
endfunction

3. function is_diagonal_matrix(M)
[c,d]=size(M)
if(c-d)
fprintf(" The matrix is not square ")
elseif (!(c-d))
if(isdiag(a))
fprintf(" The matrix is diagonal! ")
else
fprintf(" It is not diagonal! ")
endif
endif
endfunction

4. function is_lower_triangular_matrix(M)
[c,d]=size(M)
if(c-d)
fprintf(" The matrix is not square ")
elseif (!(c-d))
if(istril(a))
fprintf(" The matrix is lower triangular! ")
else
fprintf(" It is not lower triangular! ")
endif
endif
endfunction


Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students