How to compare two input arguments of type table
Afficher commentaires plus anciens
I am trying to import my data from .csv file. This data includes characters and dates(with time). I imported this data as a table and now try to perform simple operations such as comparing the character field with a value or compare two date field. I used the following:
formatSpec = '%f%C%C%C%{MM/dd/yyyy HH:mm}D%{MM/dd/yyyy HH:mm}D';
T = readtable('Flights.csv','Delimiter',',', ... 'Format',formatSpec);
T
and the output looks like this:
T =
FLIGHTID ACID DEPTAIRPORT ARRAIRPORT DEPTDATE ARRDATE
______________ _______ ___________ __________ ________________ ________________
20160100000000 DAL1448 ATL DTW 01/06/0016 12:10 01/06/0016 17:10
Now I need to check to see if DEPTDATE is earlier than ARRDATE or later. I used the following syntax and got an error:
if T(1,5) > T(1,6) 1 else 2 end
error: Undefined operator '>' for input arguments of type 'table'.
Error in input (line 12) if T(1,5) > T(1,6)
Also, how can I check to see if T(1,2) = 'DAL1448' and if yes, then print "match found"?
Thanks for your help.
Réponse acceptée
Plus de réponses (1)
Lucie Sanchez
le 9 Avr 2019
Hi,
I've got the same issue, before upload Matlab it worked but now it crases. It's not my code and I don't understand a lot so I don't really know where is the problem.
for n=1:size(correct,1)
if correct(n,1)>0 || correct(n,2)>0
peaks=polyval(parms(n,:),ex)
end
end
But I receive an error message:
"Undefined operator '>' for input arguments of type 'table'.
if correct(n,1) > 0 || correct(n,2) > 0 %test for no-filter condition"
I tried to change parentheses by curly braces after some research but unsuccessfully...it leads to other errors...
1 commentaire
Peter Perkins
le 10 Avr 2019
Lucie, you should start a new thread.
It appears that "correct" used to be a numeric matrix, and now it's a table. That's happening upstream of the code you are looking at, you you need to provide more context.
In a new thread.
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!