Filter löschen
Filter löschen

count number of index in many vector

4 Ansichten (letzte 30 Tage)
Firas Al-Kharabsheh
Firas Al-Kharabsheh am 2 Apr. 2016
Bearbeitet: Walter Roberson am 2 Apr. 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 Kommentar
Jung Soo Park
Jung Soo Park am 2 Apr. 2016
Bearbeitet: Walter Roberson am 2 Apr. 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

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 2 Apr. 2016
cellfun( @length, A)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by