How to create a uitable from extracted data from a struct in app designer?
1 次查看(过去 30 天)
显示 更早的评论
I am having some trouble with creaating a uitable from the extracted data from a struct in app designer. I first coded this:
datafile = fullfile('\\fl51s01\ClearwaterEngrg\CETLab','AccelQuery.mat');
rmdData=load(datafile)
rmdDatanames=fieldnames(rmdData)
SERIAL_NUMBER=cellfun(@(SERIAL_NUMBER)(rmdData.(SERIAL_NUMBER)),fieldnames(rmdData))
BIA_COF_0=cellfun(@(BIA_COF_0)(rmdData.(BIA_COF_0)),fieldnames(rmdData))
BIA_COF_1=cellfun(@(BIA_COF_1)(rmdData.(BIA_COF_1)),fieldnames(rmdData))
BIA_COF_2=cellfun(@(BIA_COF_2)(rmdData.(BIA_COF_2)),fieldnames(rmdData))
BIA_COF_3=cellfun(@(BIA_COF_3)(rmdData.(BIA_COF_3)),fieldnames(rmdData))
BIA_COF_4=cellfun(@(BIA_COF_4)(rmdData.(BIA_COF_4)),fieldnames(rmdData))
SF_COF_0=cellfun(@(SF_COF_0)(rmdData.(SF_COF_0)),fieldnames(rmdData))
SF_COF_1=cellfun(@(SF_COF_1)(rmdData.(SF_COF_1)),fieldnames(rmdData))
SF_COF_2=cellfun(@(SF_COF_2)(rmdData.(SF_COF_2)),fieldnames(rmdData))
SF_COF_3=cellfun(@(SF_COF_3)(rmdData.(SF_COF_3)),fieldnames(rmdData))
SF_COF_4=cellfun(@(SF_COF_4)(rmdData.(SF_COF_4)),fieldnames(rmdData))
In an effort to extract the values from the fields of the struct. I then coded:
mergetables=struct2array({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});
uidata=uitable(uifigure,'Data',{mergetables});
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 then got an error for mergetables:
Undefined function 'struct2cell' for input arguments of type 'cell'.
Error in struct2array (line 10)
c = struct2cell(s);
Any suggestions or resolutions to apply?
0 个评论
回答(1 个)
Jalaj Gambhir
2020-8-26
Hi,
The issue is occuring because you are passing cell arguments to the function. As you are converting from struct, the input arguments must be struct. Look at the examples that might guide you.
Hope this helps.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!