Displaying values for more than 2 counts

9 vues (au cours des 30 derniers jours)
kash
kash le 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

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 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

Plus de réponses (0)

Catégories

En savoir plus sur Modeling dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by