Displaying values for more than 2 counts

I have values as
R =
{6x4 cell}
{5x4 cell}
{4x4 cell}
{3x4 cell}
in which R{1,1} (has taken from variable editor)
'' 'c1' 'c2' 'c3'
'Par1' 'M' 'P' 'M'
'Par2' 'SPSO' 'PSO' 'MPSO'
'Par3' 'MPSO' 'PSO' 'PSO'
'Par4' 'MPSO' 'MPSO' 'MPSO'
'Par5' 'SPSO' 'PSO' 'PSO'
R{2,1} and so on
'' 'c1' 'c2' 'c3'
'Par2' 'S' 'S' 'P'
'Par3' 'MPSO' 'PSO' 'PSO'
'Par4' 'MPSO' 'MPSO' 'MPSO'
'Par5' 'SPSO' 'PSO' 'PSO'
Taking first value in c1(in R{1,1} the first value is 'M' if 'M' is >=2 ) i want to display as
result{1,1}
'' c1' 'c3'
'Par1' 'M' 'M'
'Par2' 'SPSO' 'MPSO'
'Par3' 'MPSO' 'PSO'
'Par4' 'MPSO' 'MPSO'
'Par5' 'SPSO' 'PSO'
In R{2,1} the first value is S(two 'S' are there)so
result{2,1}
'' c1' 'c2'
'Par2' 'S' 'S'
'Par3' 'MPSO' 'PSO'
'Par4' 'MPSO' 'MPSO'
'Par5' 'SPSO' 'PSO'
and so on please help

 採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 9 月 1 日

0 投票

result = R;
for jj = 1:numel(result)
[c,c,c] = unique(result{jj}(2,2:end));
[i1,i1] = max(histc(c,1:max(c)));
result{jj} = result{jj}(:,[true,c == c(i1)]);
end

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeModeling についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by