Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %script.m:
- n=input('Numar elemente: ');
- k=input('Numar matrici rare: ');
- l=0;
- for i=1:n
- if l<k
- disp(['Pozitia ',num2str(i)]);
- B=input('Matricea rara este: ');
- s(i).date=sparse(B);
- l=l+1;
- else
- s(i).date=input(['s(',num2str(i),').date=']);
- end
- end
- [mr mv]=structura_matrice_rara_vida(s,n);
- disp(['Matrice rara: ',num2str(mr)]);
- disp(['Matrice vida: ',num2str(mv)]);
- %structura_matrice_rara_vida.m:
- function [mr mv]=structura_matrice_rara_vida(s,a)
- mr=0;
- mv=0;
- for i=1:a
- [l c]=size(s(i).date);
- if issparse(s(i).date)==1
- mr=mr+1;
- end
- if l==0 && c==l
- mv=mv+1;
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement