Displaying values for more than 2 counts

1 Ansicht (letzte 30 Tage)
kash
kash am 1 Sep. 2012
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

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 1 Sep. 2012
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

Weitere Antworten (0)

Kategorien

Mehr zu Modeling finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by