How to combine two tables with same variable name without change anything in the table
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have performed a lot of experiments and got over 50 xlsx files with over 10 arrays data in it, and each of them has the same variable names and datas, such as:
1. Experiment 1: made at 2018, the injection rate is 0.146ml/min
The content in the xlsx flie which was recored is:
Slice Time X Y
2018-bz-10-0.146-001.png 0.1 123.10 155.84
2018-bz-10-0.146-002.png 0.3 115.28 155.443
2018-bz-10-0.146-003.png 0.6 116.36 155.406
2. Experiment 2: made at 2018, the injection rate is 2.128ml/min
The content in the xlsx flie which was recored is:
Slice Time X Y
2018-bz-10-2.128-001.png 18.5 11.68 128.08
2018-bz-10-2.128-002.png 36.4 130.89 155.4
P.S. The second file just have two slices as the camera for the image slices stops earlier.
I use 'readtable' to import these xlsx files. As there are too much of them, I decide to combine all of the xlsx into one parallel table, and save it as one xlsx. Just like
Slice Time X Y Slice Time X Y
2018-bz-10-2.128-001.png 18.5 11.68 128.08 2018-bz-10-0.146-001.png 0.1 123.10 155.84
2018-bz-10-2.128-002.png 36.4 130.89 155.4 2018-bz-10-0.146-002.png 0.3 115.28 155.443
2018-bz-10-2.128-003.png 45.4 NaN NaN
Therefore, depend on this single xlsx, I can efficiently organize my datasets and copy these data to other places, while any of the data in it could be traced to its original source. Furthermore, I could modify the .m to particularly extract two arrays in all xlsx into one xlsx for further comparisons.
So could any help me about this? It seems just a simple combination of data, but matlab told me
Cannot find a common table variable to use as a key variable.
Or:
Duplicate variable name: 'Slice'.
So any solutions? Thanks!
3 Commenti
Peter Perkins
il 14 Mar 2019
This question doesn't make sense to me. Here are your two tables:
>> A = readtable('1.xlsx')
A =
3×4 table
Slice Time X Y
____________________________ ____ ______ ______
{'2018-bz-10-0.146-001.png'} 0.1 123.1 155.84
{'2018-bz-10-0.146-002.png'} 0.3 115.28 155.44
{'2018-bz-10-0.146-003.png'} 0.6 116.36 155.41
>> B = readtable('2.xlsx')
B =
2×4 table
Slice Time X Y
____________________________ ____ ______ ______
{'2018-bz-10-2.128-001.png'} 18.5 11.68 128.08
{'2018-bz-10-2.128-002.png'} 36.4 130.89 155.4
They have no values in common on which to join them, nor do they have the same number of rows. I don't see any way to sensibly put them side-by-side.
If you want something otyher than
>> [A; B]
ans =
5×4 table
Slice Time X Y
____________________________ ____ ______ ______
{'2018-bz-10-0.146-001.png'} 0.1 123.1 155.84
{'2018-bz-10-0.146-002.png'} 0.3 115.28 155.44
{'2018-bz-10-0.146-003.png'} 0.6 116.36 155.41
{'2018-bz-10-2.128-001.png'} 18.5 11.68 128.08
{'2018-bz-10-2.128-002.png'} 36.4 130.89 155.4
you will need to explain much more clearly.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Tables in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!