Deleting erroneous data from a table

5 ビュー (過去 30 日間)
James Cross
James Cross 2022 年 11 月 30 日
回答済み: Kartik 2023 年 3 月 21 日
I have multiple months of data consisting of 96 entries per day. I need a code segment that will allow me to quickly check each day ( 1 thru 31) to see if it in fact has the required number of entries (should be 96). I need to identify these items indices and remove them from ixt.
So far I have this mess: (I changed the daily input to 97 in an attempt to force a reaction). There has to be a better way... since this didn't work.
ixt = find(deviceColumn == deviceNumber);
dailyInput = 97;
data_check = DateTime(ixt);
sampleDays = dateshift(data_check,'start','day');
check_results = groupsummary(table(sampleDays),1);
days_v = height(check_results(:,2));
ixt_indrem = zeros(1,days_v);
counts = table(check_results(:,2));
dailyInput_t = table(96*ones(31,1));
ixt_indremove = setdiff(counts,dailyInput_t);
I tried using ixt_indremove = setdiff(counts,dailyInput_t); but I keep getting this "Error using tabular/union
A and B must both be tables, or both be timetables." which confuses me because my variables "counts" and "dailyInput_t" are both tables of the same size.
  1 件のコメント
Jonas
Jonas 2022 年 11 月 30 日
please attach our data in a mat file

サインインしてコメントする。

回答 (1 件)

Kartik
Kartik 2023 年 3 月 21 日
Hi,
The error message you are receiving suggests that 'counts' and 'dailyInput_t' are not both tables or timetables, as required by the 'setdiff' function. One way to fix this is to convert both 'counts' and 'dailyInput_t' into ordinary arrays using the 'table2array' function before passing them to 'setdiff'.

カテゴリ

Help Center および File ExchangeTables についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by