B = bandwidth(A,type) returns
the bandwidth of
matrix A specified by type.
Specify type as 'lower' for
the lower bandwidth, or 'upper' for the upper bandwidth.

The upper and lower bandwidths of a matrix
are measured by finding the last diagonal (above or below the main
diagonal, respectively) that contains nonzero values.

That is, for a matrix A with elements A_{ij}:

The upper bandwidth B_{1} is
the smallest number such that $${A}_{ij}=0$$ whenever $$j-i>{B}_{1}$$.

The lower bandwidth B_{2} is
the smallest number such that $${A}_{ij}=0$$ whenever $$i-j>{B}_{2}$$.

Note that this measurement does not disallow intermediate diagonals
in a band from being all zero, but instead focuses on the location
of the last diagonal containing nonzeros. By convention, the upper
and lower bandwidths of an empty matrix are both zero.

Tips

Use the isbanded function
to test if a matrix is within a specific lower and upper bandwidth.

Extended Capabilities

C/C++ Code Generation Generate C and C++ code using MATLAB® Coder™.

Usage notes and limitations:

Code generation does not support sparse matrix inputs for this
function.

Thread-Based Environment Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.