One way to check if two tables are the same is to use the isequal
function in Matlab. This function returns a logical value true
if both inputs are the same size and contain the same data elements; otherwise, it returns false
.
If the tables are not the same and you want to show the differences without using the keys, you can use the table2array
function to convert the tables to arrays and then compare them using the ==
operator to get a logical array that indicates where the values in the tables are different. The array2table
function can then be used to convert the logical array back to a table with the same size and variable names as the original tables.
Here's an example code snippet that demonstrates how to do this for two tables t1
and t2
:
main.m381 chars12 lines
Note that this method only works if the two tables have the same number of rows and variables with the same variable names.
gistlibby LogSnag