フィルターのクリア

Displaying the most number of counts

1 回表示 (過去 30 日間)
kash
kash 2012 年 7 月 19 日
A=
'' 'c1' 'c2' 'c3' 'c4' 'c5'
'yar12' 'hi' 'hello' 'hi' 'hello' 'hi'
'yar13' hello' 'hi' 'hi' 'hello' 'hi'
'yar14' 'hi' 'hi' 'hi' 'hello' 'hello'
'yar15' 'hello' 'hi' 'hi' 'hi' 'hi'
'yar16' 'hello' 'hi' 'hi' 'hello' 'hello'
'yar17' 'hi' 'hi' 'hi' 'hi' 'hi'
With respect to c1 i want to display only the same value(as c1 value) having more than 2 counts for example
'yar12' has 'hi'(considering c1 as value) thrice(c1 to c5) so i want to display
'yar12' 'hi' 'hello' 'hi' 'hello' 'hi'
yar13 should no be considered because its has 'hello'(considering c1 as value) twice (from c1 to c5)twice,so i need output as
'yar12' 'hi' 'hi' 'hi'
'yar14' 'hi' 'hi' 'hi'
'yar16' 'hello' 'hello' 'hello'
'yar17' 'hi' 'hi' 'hi' 'hi' 'hi'
please provide assistance
  6 件のコメント
Jan
Jan 2012 年 7 月 20 日
The similarities between kash's and Pat's question are surprising. @Pat and kash: Are you working on the same problem?
Walter Roberson
Walter Roberson 2012 年 7 月 20 日
In the past, kash and Pat were taking exactly the same course at the same location (they indicated), and yet their assignments were not always exactly the same. My speculation would be that they are still taking the same course together but that the instructors give each student slightly different assignments.

サインインしてコメントする。

採用された回答

Thomas
Thomas 2012 年 7 月 19 日
A very round about way of doing this but works..
a = { '' 'c1' 'c2' 'c3' 'c4' 'c5'
'yar12' 'hi' 'hello' 'hi' 'hello' 'hi'
'yar13' 'hello' 'hi' 'hi' 'hello' 'hi'
'yar14' 'hi' 'hi' 'hi' 'hello' 'hello'
'yar15' 'hello' 'hi' 'hi' 'hi' 'hi'
'yar16' 'hello' 'hi' 'hi' 'hello' 'hello'
'yar17' 'hi' 'hi' 'hi' 'hi' 'hi'};
for count=2:size(a,1)
out(count,:)=strcmp(a(count,:),a(count,2));
check_sum(count)=sum(out(count,:));
end
output=a(check_sum>2,:);
p=out(check_sum>2,:)
p(:,1)=1;
[r,c]=find(p==1);
for ii=1:length(r)
a=r(ii);
b=c(ii);
final(a,b)=output(a,b);
end
final

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by