Effacer les filtres
Effacer les filtres

count number of index in many vector

4 vues (au cours des 30 derniers jours)
Firas Al-Kharabsheh
Firas Al-Kharabsheh le 2 Avr 2016
if i have
A{1} = 2
8
1
1
then the solution will be 4
A{2} = 1
3
5
4
5
2
then the solution will be 6
A{3} = 4 5 3 2 5 3 1
then the solution will be 7
i need this solution for A{k}
  1 commentaire
Jung Soo Park
Jung Soo Park le 2 Avr 2016
Modifié(e) : Walter Roberson le 2 Avr 2016
I hope this is what you want..
I assume k=4 and made A{4} with 14 numbers and expected so expected solution is 14.
k=4;
A=[];
A{1}=[2;8;1;1] ;
A{2}=[1;3;5;4;5;2];
A{3} = [4,5,3,2,5,3,1];
A{4}=[4,5,3,2,5,3,1,4,5,3,2,5,3,1];
S=zeros(1,k);
for i=1:k
s=(size(A{i}));
S(1,i)=max(s);
end
S

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 2 Avr 2016
cellfun( @length, A)

Catégories

En savoir plus sur Matrix Indexing 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!

Translated by