Comparing and exporting data from 3 tables

Asked by Sigurd Otterå

Sigurd Otterå (view profile)

on 10 Jul 2019
Latest activity Answered by Dheeraj Singh

Dheeraj Singh (view profile)

on 29 Jul 2019
Create a script that first takes in a large table (main table, very large), table1, and a smaller table, table2. The script should then find common elements in the main table and in the second table table 2 for a given column number and count the number as a result. Then the function should export them as a new table where the common elements are colored (eg green).
Then, the script must take a table and count common elements in a third table, table3, for a given column, and count them as a result. Then the function should export them as a new table where the common elements are colored (eg red). It should also count the number of common elements as a result.
Then we take and find common elements from table2 and table3 and color the orange in the main table, also count the number of common elements. , Then it must export a total table based on the main table, where the common elements from table 2 are colored green in the main table and the common elements from table 3 are colored red and those common to both table 2 and table 3 are colored orange.

Release

R2017b

Answer by Dheeraj Singh

Dheeraj Singh (view profile)

on 29 Jul 2019

I understand that you want to compare columns of different tables and then export them as a new table and highlight the common element with different colors (red, green, orange).
For comparing the elements of the column, you can use the following strategy:
Since the number of elements in the columns is different for all tables you can use intersect and numel to count number of common elements.
commonElements=intersect(table1(: ,columnName),table2(:,columnName));
You can then use the App Designer to export the table and highlight common elements.
For plotting the table to highlight the common elements you can refer to this MATLAB Answer to set the color of each cell of the table: