Uitable data, error using horzcat
1 view (last 30 days)
Show older comments
I am having some trouble with merging and displaying array tables into one uitable in the app designer.
I first have:
rmdData=importdata('AccelQuery.mat')
SERIAL_NUMBER=rmdData.('SERIAL_NUMBER')
BIA_COF_0=rmdData.('BIA_COF_0')
BIA_COF_1=rmdData.('BIA_COF_1')
BIA_COF_2=rmdData.('BIA_COF_2')
BIA_COF_3=rmdData.('BIA_COF_3')
BIA_COF_4=rmdData.('BIA_COF_4')
SF_COF_0=rmdData.('SF_COF_0')
SF_COF_1=rmdData.('SF_COF_1')
SF_COF_2=rmdData.('SF_COF_2')
SF_COF_3=rmdData.('SF_COF_3')
SF_COF_4=rmdData.('SF_COF_4')
This gets the data from the fields within a structure.
I then use the code below to merge the tables and create the uitable:
mergetables=[SERIAL_NUMBER,BIA_COF_0,BIA_COF_1,BIA_COF_2,BIA_COF_3...
,BIA_COF_4,SF_COF_0,SF_COF_1,SF_COF_2,SF_COF_3,SF_COF_4];
mergetable1=array2table(mergetables);
uitdata=uitable(uifigure,'Data',mergetable1);
uitdata.ColumnName={'Accel S/N' ;'BIA_COF_0'; 'BIA_COF_1'; 'BIA_COF_2'; 'BIA_COF_3' ;'BIA_COF_4';...
'SF_COF_0'; 'SF_COF_1'; 'SF_COF_2' ;'SF_COF_3' ;'SF_COF_4'};
I intend the mergetables to have each single array in different columns.
I happen to receive this error for the mergetables:
Error using horzcat
Dimensions of arrays being concatenated are not consistent. Consider converting input arrays to the same type before concatenating.
How should I correct this in order to get the double arrays from the data all merged into one and as well as displaying those values inside the uitable?
2 Comments
Walter Roberson
on 13 Jul 2020
mergetable1 = table(SERIAL_NUMBER,BIA_COF_0,BIA_COF_1,BIA_COF_2,BIA_COF_3...
,BIA_COF_4,SF_COF_0,SF_COF_1,SF_COF_2,SF_COF_3,SF_COF_4, 'variablenames', {'Accel S/N' ;'BIA_COF_0'; 'BIA_COF_1'; 'BIA_COF_2'; 'BIA_COF_3' ;'BIA_COF_4';...
'SF_COF_0'; 'SF_COF_1'; 'SF_COF_2' ;'SF_COF_3' ;'SF_COF_4'});
and possibly you would not need to set the ColumnName of the uitable.
Note: table variable with a space or / in the name requires R2019b or later.
Answers (0)
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!