How to create a uitable from extracted data from a struct in app designer?

조회 수: 4 (최근 30일)
Alexandra Philip
Alexandra Philip 2020년 7월 15일
답변: Jalaj Gambhir 2020년 8월 26일
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?

답변 (1개)

Jalaj Gambhir
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.

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by