How to assign next matching string
    1 vue (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    Mekala balaji
      
 le 14 Oct 2018
  
    
    
    
    
    Réponse apportée : the cyclist
      
      
 le 14 Oct 2018
            Hi, I have below cell array,
STD AMHAT00 PAK497.00   34  Same  12
AT  AAHAT00 YAH00K      34        56
AT  AAHAT00 YAH00K      34        56
STD AAHAT00 PAK897.00   34  Diff  12
STD AAHAT00 PAK897.00   34  same  12
AT  AAHAT00 AKAH00K     34        56
AT  AAHAT00 AKAH00K     84        56
AT  AAHAT00 AKAH00K     84        56
STD AAHAT00 NAK837.00   34  Same  12
STD AAHAT00 NAK837.00   34  Same  45
The 5th column Diff or same is based on column2. If the previous STD column2 is different name, then it lableas Diff, and if it is same then it labeled as same.
Output rule: For each STD, just previous AT rows &5th column is labeled same as the first STD column5. Desired output:
AT  AAHAT00 YAH00K      34  Diff   56
AT  AAHAT00 YAH00K      34  Diff   56
AT  AKHAT50 AKAH00K     34  Same   56
AT  AKHAT50 AKAH00K     84  Same   56
AT  AKHAT50 AKAH00K     84  Same   56
0 commentaires
Réponse acceptée
  the cyclist
      
      
 le 14 Oct 2018
        If c is your input array, then
for nc = size(c,1)-1:-1:1;
    if not(ismember(lower(c{nc,5}),{'same','diff'}))
        c(nc,5) = c(nc+1,5);
    end
end
output = c(ismember(c(:,1),'AT'),:)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur Data Acquisition Toolbox Supported Hardware dans Help Center et File Exchange
			
	Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

