I have to tables, an old one and a new one.
Is there a function or a way to check what the differences are between 2 tables based on checking rows?
So in this example, my output needs to be row 2 cause the other rows are identical.

 채택된 답변

Cris LaPierre
Cris LaPierre 2022년 8월 26일

1 개 추천

You could try using setdiff.
If A and B are tables or timetables, then setdiff returns the rows from A that are not in B.

댓글 수: 1

Adam Danz
Adam Danz 2026년 1월 13일
See also setxor which will list rows rows from table1 and table2 that differ.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Voss
Voss 2022년 8월 26일

0 개 추천

If your tables are the same size and both contain all numeric data, then this would work:
% create some tables:
t1 = table([1;2;3],[4;5;6],[7;8;9])
t1 = 3×3 table
Var1 Var2 Var3 ____ ____ ____ 1 4 7 2 5 8 3 6 9
t2 = table([1;2;3],[4;15;6],[7;8;9])
t2 = 3×3 table
Var1 Var2 Var3 ____ ____ ____ 1 4 7 2 15 8 3 6 9
% find rows that are different:
row_different = find(~all(t1{:,:} == t2{:,:},2))
row_different = 2
dpb
dpb 2022년 8월 26일
편집: dpb 2022년 8월 26일

0 개 추천

ix=(any(A{:,:}~=B{:,:},2)&all(isfinite([A{:,:} B{:,:}]),2))|(all(isnan(A{:,:})~=isnan(B{:,:}),2));
This is somewhat tricky because NaN compares as isequal() to nothing, including itself so it will always show up.

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

제품

릴리스

R2022a

질문:

2022년 8월 26일

댓글:

2026년 1월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by