How to extracy table rows by date?

How can one extract table rows by unique dates? If there is a data set where the first column is the date (MM/dd/yyyy), can one create a matrix with unique dates and then extract for each only the rows containing that date?
ExpirationDates = quotedata(:,1); %extract expiration dates
uniqueDates = unique(ExpirationDates); %build expiration dates table
quotedata = table2timetable(quotedata);
for k=1:height(uniqueDates)
thisDate = (uniqueDates(k,:));
indexesWithThisDate = (ExpirationDates == thisDate);
% Extract all rows with this date and put into a cell array.
theseData = array(indexesWithThisDate, 12); % Get col 12
% Assign to a new cell
ca{k} = theseData;
end
I get the following error message:
"Undefined operator '==' for input arguments of type 'table'.
Error in QuotesProcessor (line 13)
indexesWithThisDate = (ExpirationDates == thisDate);"

回答(1 个)

Peter Perkins
Peter Perkins 2019-5-14
Looking at your code, you seem to be creating a timetable with no data, just row times. That doesn't seem useful. But then "array" is, maybe, a table or something with data? This doesn't seem the right way to go about things.
The answer to your specific question is, (ExpirationDates.Time == thisDate). But there have to be better ways to go about whatever it is you are doing.

类别

在 帮助中心 和 File Exchange 中查找有关 Tables 的更多信息

产品

版本

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by