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

5 次查看(过去 30 天)
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?

采纳的回答

Ridwan Alam
Ridwan Alam 2019-12-14
T1(ismember(table2array(T1(:,1)),table2array(T2)),2) = T2;
T1(ismember(table2array(T1(:,1)),table2array(T3)),3) = T3;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by