innerjoin of table of tables

4 ビュー (過去 30 日間)
Dan
Dan 2019 年 11 月 18 日
回答済み: Samatha Aleti 2020 年 1 月 29 日
In MATLAB 2017b I cannot do an innerjoin of two tables where one or both has a table for the datatype associated with one of the variables. This was fixed in ML 2018 along with some better display support for tables of tables ... but stepping up a version of ML is not an easy option for me. Does anyone have a workaround to get innerjoin to work in 2017b?
Here is some code that runs in 2018a but not 2017b
a = cellfun(@(x)table(x,'variablenames',{'b'}),num2cell(1:10),...
'uniformoutput',false);
b = table((1:10)',cat(1,a{:}),'variablenames',{'b','a'});
d.c = (101:2:110)';
d.b = (1:2:10)';
e=struct2table(d);
f=innerjoin(b,e,'keys','b')

回答 (1 件)

Samatha Aleti
Samatha Aleti 2020 年 1 月 29 日
You may do this by converting table of tables into table of arrays using “table2array” as follows:
a = cellfun(@(x)table(x,'variablenames',{'b'}),num2cell(1:10),...
'uniformoutput',false);
conv = zeros(1,10);
for i = 1:10
conv(i) = table2array(a{i});
end
b = table((1:10)',cat(1,conv'),'variablenames',{'b','a'});
d.c = (101:2:110)';
d.b = (1:2:10)';
e=struct2table(d);
f=innerjoin(b,e,'keys','b');

カテゴリ

Help Center および File ExchangeTables についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by