Uicontrol, struct cell array to uitable

조회 수: 12 (최근 30일)
Pi Height
Pi Height 2018년 8월 4일
다시 열림: Walter Roberson 2018년 12월 22일
Hey guys,
I have some issues with an uitable and different data types. I have a struct called data with the fields 'Properties' and 'Values' which get me a field 'DT'.
'data.Properties'
'data.Values'
'data.DT = {data.Properties, data.Values}'
I want to get a table like this one but with 'data.DT' and with the uicontrol objects 'gui.checkbox{k}':
How is it possible to create the uitable with data.DT and not with data.DT1?
Is it possible to get my uicontrol objects 'gui.checkbox{k}' in a column of the uitable as well?
function Test_UiTable_V2()
%%Test Function
close all
data = createData();
gui = createInterface();
function data = createData()
%%Data from Excel
data.Properties = {'a';'b';'c';'d';'e'};
data.Values = [1;2;3;4;5];
data.DT = {data.Properties, data.Values};
data.DT1 = {false,'a',1;false,'b',2;false,'c',3};
end
function gui = createInterface()
%%Window figure and Panel
gui.Window = figure('Units','normalized','Outerposition',[0 0 1 1],...
'Name','Test ', ...
'NumberTitle', 'off','MenuBar', 'none');
gui.panel = uipanel('Units','pixels','Title','Test',...
'FontSize',10,'Position',[15 400 300 300]);
%%Gui.Checkboxes
i = size(data.Properties, 1);
for k=1:i
gui.checkbox{k} = uicontrol('parent',gui.panel,'Style','checkbox','tag', sprintf('checkbox%d', k),'string',data.Properties(1*k),...
'Position',[10 150-k*20 150 20],'callback',@(src,evt)Checkbox_(src,evt,k));
end
%%UI_Table with manual data input from data.DT1
gui.table_Properties = uitable('parent',gui.panel,'ColumnName',...
{'Checkboxes','Properties', 'Values'},'RowName',{},...
'ColumnWidth',{'auto'},'Position',[40 20 200 200]);
gui.table_Properties.Data = data.DT1; % This should work with data.DT
end
end
  댓글 수: 2
Jan
Jan 2018년 8월 4일
편집: Jan 2018년 8월 4일
struct of several fields including a cell array called
'data.Properties'
You cannot use a dot in the name of a cell array. Usually the quotes mean, that this is a chat vector, therefore your first sentence is not clear already.
You mean:
I have a struct called |data| with the fields 'Properties' and
'Values'.
You forgot to mention what your question is.
Note:
[i,] = size(data.Properties);
This is no valid Matlab syntax. Do you mean:
i = size(data.Properties, 1);
Pi Height
Pi Height 2018년 8월 4일
Thanks for your help. I hope i got it clear now.

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

답변 (2개)

Jan
Jan 2018년 8월 5일
No, this cannot work. You cannot create the checkboxes by uicontrol and move them magically into the uitable. I do not see a reason to try this. The documentation of uitable explains, how checkboxes are created in the table, so use this method instead of inventing a new one.

Pi Height
Pi Height 2018년 8월 5일
Ok thanks for the information, but how do I get a cell array to my uitable? It doesn't work with a char or cell2mat format as well.

카테고리

Help CenterFile 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!

Translated by