Hello!
I would like to load data from a structure 'struc' into a GUIDE table 'file_table'. The structure has the following fields:
file_name: {8×1 cell}
serial_number: {8×1 cell}
event_date_time: {8×1 cell}
ppv: {8×1 cell}
shot_assignment: {8×2 cell}
instlocs: [8×2 double]
instadd: [8×1 string]
I just use
set(handles.file_table,'Data',struc);
I have tried a whole bunch of changes to the structure (the structure is from someone else's coding), with no success. What am I doing wrong? I can trim the instlocs and shot_assignment fields to be 8x1.
Thanks!.

 채택된 답변

Geoff Hayes
Geoff Hayes 2021년 9월 29일

0 개 추천

Douglas - perhaps you need to convert the struct to a table before setting the uitable. Try using struct2table to see if that helps.

댓글 수: 3

Douglas Anderson
Douglas Anderson 2021년 9월 29일
Hello Geoff,
As Walter Roberson indicated once (I do read the old answers!), it appears that GUIDE created figures can't use tables created this way. Any other thoughts? I am just having trouble getting data into even a stupid junk table!
Thanks!
Doug
Douglas - once you convert the struct to a table, then convert the table to a cell array with table2cell. That will just give you the data (not the column headers). For example (from the struct2table function),
S.Name = {'CLARK';'BROWN';'MARTIN'};
S.Gender = {'M';'F';'M'};
S.SystolicBP = [124;122;130];
S.DiastolicBP = [93;80;92];
T = struct2table(S);
C = table2cell(T);
set(handles.uitable1, 'Data', C, 'ColumnName', T.Properties.VariableNames);
Douglas Anderson
Douglas Anderson 2021년 10월 1일
Thank you very much, Geoff!
That works. Amazing how roundabout one sometimes has to go.
Doug

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Identification에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2021년 9월 28일

댓글:

2021년 10월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by