Table variable comparison.
    3 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    Amritpal Kaur
 le 22 Avr 2016
  
    
    
    
    
    Réponse apportée : Guillaume
      
      
 le 22 Avr 2016
            So I have a table ( lq is the variable name) with a lot of data. The first 2 columns are ip addresses and the next 2 rows are some data related to that. the column names are like:
ip neighbour blah blah2
So I need to make subtables from certain data in this table, I wrote:
T1 = table(lq.ip=='192.168.2.101',lq.neighbor=='192.168.2.102', timestamp,lq);
Which sadly, doesn't create a new table with all the datapoints for ip value and neighbour value as shown. Where have I mistaken?
Thanks.
0 commentaires
Réponse acceptée
  Guillaume
      
      
 le 22 Avr 2016
        1) Do not use == to compare strings, use strcmp
2) This is not how you index tables at all
%if you want all the columns for the matching rows:
newtable = lq(strcmp(lq.ip, '192.168.2.101') & strcmp(lq.neighbor, '192.168.2.102'), :) 
%if you just want the timestamp column:
newtable = lq(strcmp(lq.ip, '192.168.2.101') & strcmp(lq.neighbor, '192.168.2.102'), lq.timestamp)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur Image Data 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!
