%% Test Square Matrix
% Create a 5-by-5 square matrix with nonzero diagonals above and below the main diagonal.

A = [2 3 0 0 0 ; 1 -2 -3 0 0; 0 -1 2 3 0 ; 0 0 1 -2 -3; 0 0 0 -1 2]

%
% Specify both bandwidths, lower and upper, as 1 to test if A is tridiagonal.

isbanded(A,1,1)

% The result is logical 1 (true).
%
% Test if A has nonzero elements below the main diagonal by specifying lower as 0.

isbanded(A,0,1)

% The result is logical 0 (false) because A has nonzero elements below the main diagonal.
% Copyright 2012 The MathWorks, Inc.