How to filter required data
    5 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Kanakaiah Jakkula
 il 8 Mag 2016
  
    
    
    
    
    Commentato: Kanakaiah Jakkula
 il 8 Mag 2016
            Hi,
I have below table. I want to take the data under "actual measurement" till stop, but in between there should not exist except complete or paused or stop. for example I want the below cases:
    actual measurement           start              2016/4/5           
    complete                     BA0K2              23
    complete                     BY0P2              3
    stop                         HYT0KL             54
AND
actual measurement           start              2016/4/7           
paused                       VA0L2              89
paused                       BY0P2              3
stop                         HYT0KL             54
But I dont want:
measurement restart          start              2016/4/7           
complete                     VA0L2              89
paused                       BY0P2              3
stop                         HYT0KL             54
AND
actual measurement           start              2016/4/7 
actual measurement restart   start              2016/4/7                     
paused                       VA0L2              89
stop                         HYT0KL             54
My Table:
actual measurement           start              2016/4/5           
complete                     BA0K2              23
complete                     BY0P2              3
stop                         HYT0KL             54
measurement restart          start              2016/4/7           
complete                     VA0L2              89
paused                       BY0P2              3
stop                         HYT0KL             54
actual measurement           start              2016/4/7           
paused                       VA0L2              89
paused                       BY0P2              3
stop                         HYT0KL             54
actual measurement restart   start              2016/4/7           
paused                       VA0L2              89
stop                         HYT0KL             54
actual measurement           start              2016/4/7 
actual measurement restart   start              2016/4/7                     
paused                       VA0L2              89
stop                         HYT0KL             54
2 Commenti
  Walter Roberson
      
      
 il 8 Mag 2016
				What is the data type of this table? If it is character, are the fields separated by tab?
Risposta accettata
  Weird Rando
      
 il 8 Mag 2016
        In order for you to run this code you must convert your data (aka the table) into cell using the cell2table() and store it into variable named 'data'
result = {};
startRows = find(strcmp(data(:,1),'actual measurement'));
stopRows = find(strcmp(data(:,1),'stop'));
nloop = length(startRows);
for i = 1:nloop
      sectionStop = find(startRows(i)<stopRows,1,'first');
      if strcmp(data(startRows(i)+1:stopRows(sectionStop)-1,1),'complete') | strcmp(data(startRows(i)+1:stopRows(sectionStop)-1,1),'paused')
          result = [result; data(startRows:stopRows(sectionStop),:)];
      end
  end
0 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


