Filter löschen
Filter löschen

How do I combine data tables where there are different row lengths?

8 Ansichten (letzte 30 Tage)
From my cell arrays, I have converted each output into a table in matlab which I have attached as excel files for clarity ( I could not convert the cell outputs into character vectors of different lengths, so made them into tables instead).
Expected removal table contains 61 rows and 1 column (T1 in matlab)
Kept table contains 45 rows and 1 column (T2 in matlab)
Deleted table contains 16 rows and 1 column (T3 in matlab)
Please find attached my data.
How would I go about combining these tables together, when I want the rownames to align, and then the rest of the cells contain NaN or NA when they don't. I have attached an excel file with this done (combined_expect_kept_deleted). However, I need code to automate this.
If I could have converted the data into three separate character vectors, I would have used padcat to concatenate the vectors of different lengths, using NaNs etc. But my cell2mat does not work, and not sure how else to get the output into character vector format from a cell.
Does anybody have any suggestions please?

Akzeptierte Antwort

Ridwan Alam
Ridwan Alam am 14 Dez. 2019
T1(ismember(table2array(T1(:,1)),table2array(T2)),2) = T2;
T1(ismember(table2array(T1(:,1)),table2array(T3)),3) = T3;

Weitere Antworten (0)

Kategorien

Mehr zu Tables finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by