Deleting erroneous data from a table
조회 수: 1 (최근 30일)
이전 댓글 표시
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개)
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'.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!