# innerjoin of table of tables

2 visualizzazioni (ultimi 30 giorni)
Dan il 18 Nov 2019
Risposto: Samatha Aleti il 29 Gen 2020
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')
##### 0 CommentiMostra -1 commenti meno recentiNascondi -1 commenti meno recenti

Accedi per commentare.

### Risposte (1)

Samatha Aleti il 29 Gen 2020
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');
##### 0 CommentiMostra -1 commenti meno recentiNascondi -1 commenti meno recenti

Accedi per commentare.

### 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!