Determine if a square matrix size nxn is upper triangular a

Determine if a square matrix (size nxn) is upper triangular (a matrix with 0\'s below the diagonal). Matrix A is an example of an upper triangular matrix, which you can also use to test your program A = [1 0 0 2 4 0 10 5 9]

Solution

function uptri(A)
sum=0;
c=size(A);
boolen=ones(c(1),c(1)-1);
if c(1)==c(2)
for i=1:c(1)
for j=1:c(1)
if j<i && A(i,j)~=0
boolen(i,j)=0;
sum=1;
end
end
end
if sum==1
fprintf(\'matrix is not upper trangular\');
else
fprintf(\'matrix is upper trangular\');
end
else
fprintf(\'matrix is not square\');
end
end

above code is function of checking whether matrix is upper trangular or not just type command uptri(Matrixname) in matlab that give you a result.

 Determine if a square matrix (size nxn) is upper triangular (a matrix with 0\'s below the diagonal). Matrix A is an example of an upper triangular matrix, whic

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site