How to remove cells that have the same value at the first row, first column as the previous cell, in a cell array?
    1 vue (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
I have tried the following, being "C1" the original cell array and "C1_no_repeats" the cell array that I want to create by deleting the cells of "C1" that have a similar value at (1,1) as the previous cell of "C1":
for aa=1:size(C1)
if C1{aa}(1,1)==C1{aa+1}(1,1)
C1_no_repeats{aa+1}=[];
else C1_no_repeats{aa+1}=C1{aa+1};
end
end
It didn't work: not only C1_no_repeats{1} is empty, but C1_no_repeats stops after the first cell with repeated (1,1) values (if C1_no_repeats has 100 cells and cell 5 has the same values at (1,1) as cell 4, then C1_no_repeats has only 4 cells...)
2 commentaires
Réponses (1)
  David Hill
      
      
 le 28 Fév 2022
        There is only one repeated value in the example provided. You could round (1,1) values if you want them to be close but not exactly the same.
b=[];
for aa=1:length(indexed_finalf_before2)
  b=[b,indexed_finalf_before2{aa}(1,1)];
end
[~,idx]=unique(b,'stable');
no_repeats=indexed_finalf_before2(idx);
0 commentaires
Voir également
Catégories
				En savoir plus sur Data Types dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


