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 日

0 投票

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 ExchangeTime Series Objects についてさらに検索

製品

リリース

R2017b

質問済み:

2019 年 5 月 9 日

回答済み:

2019 年 5 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by