Displaying values for more than 2 counts

Asked by kash on 1 Sep 2012
Latest activity Edited by Image Analyst on 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

0 Comments

kash

Tags

Products

No products are associated with this question.

1 Answer

Answer by Andrei Bobrov on 1 Sep 2012
Accepted answer
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 Comments

Andrei Bobrov

Contact us