Uicontrol, struct cell array to uitable

12 Ansichten (letzte 30 Tage)
Pi Height
Pi Height am 4 Aug. 2018
Erneut geöffnet: Walter Roberson am 22 Dez. 2018
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 Kommentare
Jan
Jan am 4 Aug. 2018
Bearbeitet: Jan am 4 Aug. 2018
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 am 4 Aug. 2018
Thanks for your help. I hope i got it clear now.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Jan
Jan am 5 Aug. 2018
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 am 5 Aug. 2018
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.

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by