how to filter data by date?
3 次查看(过去 30 天)
显示 更早的评论
hi everyone
I am trying to filter records by date. I am getting error. How do I fix it?
Code:
Data = convertvars(Data, 2, @(x) datetime(x, 'InputFormat', 'yyyy-MM-dd'));
FilteredDataRealizedVol = Data(:,["TRADE_DATE","REALIZED_VOLATILITY"]);
FilteredDataRealizedVol = FilteredDataRealizedVol(FilteredDataRealizedVol(:,1) <= datetime(2016,7,18),:);
FilteredDataRealizedVol = FilteredDataRealizedVol(FilteredDataRealizedVol(:,1) >= datetime(1928,1,27),:);
Error:
Error using <=
This operation is not defined between 'table' and 'datetime'. The input that is not a table or timetable must be a numeric or
logical array.
Error in LinearRegression (line 26)
FilteredDataRealizedVol = FilteredDataRealizedVol(FilteredDataRealizedVol(:,1) <= datetime(2016,7,18),:);
Thank you
0 个评论
采纳的回答
Walter Roberson
2024-3-4
FilteredDataRealizedVol = FilteredDataRealizedVol(FilteredDataRealizedVol{:,1} <= datetime(2016,7,18),:);
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!