Deleting erroneous data from a table

조회 수: 1 (최근 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 CenterFile Exchange에서 Tables에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by