How to check a matrix is multibanded?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a sparse matrix which I need to verify whether it is multibanded or not?
0 commentaires
Réponses (1)
Chunru
le 21 Sep 2021
% Create a banded sparse matrix
B = bucky;
r = symrcm(B)
a=B(r,r);
imagesc(a);
% Check if it is banded
m = size(a,1); % assuming square matrix
lb = m;
ub = m;
for i=-m+1:0
% check the diagonal
if all(diag(a, i)==0)
lb = i;
else
break
end
end
for i=m-1:-1:0
% check the diagonal
if all(diag(a, i)==0)
ub = i;
else
break
end
end
[lb, ub]
0 commentaires
Voir également
Catégories
En savoir plus sur Sparse Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!