innerjoin of table of tables

1 visualización (últimos 30 días)
Dan
Dan el 18 de Nov. de 2019
Respondida: Samatha Aleti el 29 de En. de 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')

Respuestas (1)

Samatha Aleti
Samatha Aleti el 29 de En. de 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');

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by