A square matrix is a matrix that has the same number of rows
A square matrix is a matrix that has the same number of rows and columns. Write a function issquare that will receive a matrix as input, and return logical 1 for true if it is a square matrix, or logical 0 for false if it is not. The function should also display a sentence stating whether the inputted matrix is square or not.
Solution
%%Save as issquare.m
function result=issquare(array)
%%get rows and columsn of array
[rows cols]=size(array)
if rows==cols
%%print message
fprintf(\'Matrix is square matri\ x\')
%%set result=true
result= true;
else
fprintf(\'Matrix is not-square matrix\ \')
result=false;
end
end
-----------------------------------------------------
A=[1 2 3 ;4 5 6; 1 2 3];
Call with the file name
issquare(A)
