Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

isbanded

Determine if matrix is within specific bandwidth

Syntax

  • tf = isbanded(A,lower,upper)
    example

Description

example

tf = isbanded(A,lower,upper) returns logical 1 (true) if matrix A is within the specified lower bandwidth, lower, and upper bandwidth, upper; otherwise, it returns logical 0 (false).

Examples

collapse all

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]
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)
ans =

  logical

   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)
ans =

  logical

   0

The result is logical 0 (false) because A has nonzero elements below the main diagonal.

Create a 3-by-5 matrix.

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

     1     0     0     0     0
     2     1     0     0     0
     3     2     1     0     0

Test if A has nonzero elements above the main diagonal.

isbanded(A,2,0)
ans =

  logical

   1

The result is logical 1 (true) because the elements above the main diagonal are all zero.

Create a 100-by-100 sparse block matrix.

B = kron(speye(25),ones(4));

Test if B has a lower and upper bandwidth of 1.

isbanded(B,1,1)
ans =

  logical

   0

The result is logical 0 (false) because the nonzero blocks centered on the main diagonal are larger than 2-by-2.

Test if B has a lower and upper bandwidth of 3.

isbanded(B,3,3)
ans =

  logical

   1

The result is logical 1 (true). The matrix, B, has an upper and lower bandwidth of 3 since the nonzero diagonal blocks are 4-by-4.

Input Arguments

collapse all

Input array, specified as a numeric array. isbanded returns logical 0 (false) if A has more than two dimensions.

Data Types: single | double
Complex Number Support: Yes

Lower bandwidth, specified as a nonnegative integer scalar. The lower bandwidth is the number of nonzero diagonals below the main diagonal. isbanded returns logical 0 (false) if there are nonzero elements below the boundary diagonal, diag(A,-lower).

Upper bandwidth, specified as a nonnegative integer scalar. The upper bandwidth is the number of nonzero diagonals above the main diagonal. isbanded returns logical 0 (false) if there are nonzero elements above the boundary diagonal, diag(A,upper).

More About

collapse all

Tips

  • Use the bandwidth function to find the upper and lower bandwidths of a given matrix.

  • Use isbanded to test for several different matrix structures by specifying appropriate upper and lower bandwidths. The table below lists some common tests.

    Lower Bandwidth

    Upper Bandwidth

    Function Call

    Tests for

    00isbanded(A,0,0)

    Diagonal matrix

    11isbanded(A,1,1)

    Tridiagonal matrix

    0size(A,2)isbanded(A,0,size(A,2))

    Upper triangular matrix

    size(A,1)0isbanded(A,size(A,1),0)

    Lower triangular matrix

    1size(A,2)isbanded(A,1,size(A,2))

    Upper Hessenberg matrix

    size(A,1)1isbanded(A,size(A,1),1)

    Lower Hessenberg matrix

See Also

| | | |

Introduced in R2014a


Was this topic helpful?