Comparing and exporting data from 3 tables
6 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Dheeraj Singh
2019-7-29
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:
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!