Question: can u trans the following code from matlab to R 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)

can u trans the following code from matlab to R

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 (ij && 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

On matlab terminal, just call,

x=function_name

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!