bandwidthMatrix bandwidth
[low,up] = bandwidth(A)A should be a (non-character) numeric matrix (2D).low) and upper (up) bandwidths of A.low-th lower-diagonal or strictly above the up-th upper-diagonal are equal to zero.low and up are zeros if A is empty.bandwidth(A, type)A should be a (non-character) numeric matrix.type should be either 'upper' or 'lower'.type is 'upper', it returns the upper bandwidth of A. If otherwise, it returns the lower bandwidth.A is empty.[l, u] = bandwidth(a) to find lower and upper bandwidths of a randomly generated matrix.% Creating a random complex matrix with 30% of its entries
% being non-zero.
a=zeros(5);
i=randi(numel(a),1,ceil(numel(a)*.3));
a(i)=7+7i
% Finding lower and upper bandwidths
[l,u]=bandwidth(a)
a =
0.000 + 0.000i 7.000 + 7.000i 0.000 + 0.000i 0.000 + 0.000i 0.000 + 0.000i
0.000 + 0.000i 0.000 + 0.000i 0.000 + 0.000i 0.000 + 0.000i 0.000 + 0.000i
0.000 + 0.000i 0.000 + 0.000i 0.000 + 0.000i 7.000 + 7.000i 7.000 + 7.000i
0.000 + 0.000i 0.000 + 0.000i 7.000 + 7.000i 0.000 + 0.000i 7.000 + 7.000i
0.000 + 0.000i 7.000 + 7.000i 7.000 + 7.000i 0.000 + 0.000i 7.000 + 7.000i
l =
3.000
u =
2.000
% Creating a random complex matrix with 30% of its entries
% being non-zero.
a=zeros(5);
i=randi(numel(a),1,ceil(numel(a)*.3));
a(i)=7+7i
% Finding lower and upper bandwidths
l=bandwidth(a,'lower')
u=bandwidth(a,'upper')
a =
0.000 + 0.000i 0.000 + 0.000i 0.000 + 0.000i 0.000 + 0.000i 0.000 + 0.000i
0.000 + 0.000i 0.000 + 0.000i 0.000 + 0.000i 7.000 + 7.000i 0.000 + 0.000i
7.000 + 7.000i 0.000 + 0.000i 0.000 + 0.000i 0.000 + 0.000i 7.000 + 7.000i
0.000 + 0.000i 7.000 + 7.000i 0.000 + 0.000i 7.000 + 7.000i 0.000 + 0.000i
0.000 + 0.000i 0.000 + 0.000i 7.000 + 7.000i 0.000 + 0.000i 0.000 + 0.000i
l =
2.000
u =
2.000