|
Hi
I'm trying to create my first GUI WITHOUT using GUIDE. The GUI has several textboxes and pushbuttons, which all work fine. But I can't get an axes to show on the GUI. I'm using the following code, I've included my full code for completness.
function h = testGUI
% Define name and position variables --------------------------------------
vNames = {'nRamp'; 'pRamp'; 'xStep'; 'minY'; 'maxY'; 'attAmp';...
'attHMHW'; 'attX0'};
vPosText = [10 420 100 20
10 390 100 20
10 360 100 20
10 330 100 20
10 300 100 20
10 270 100 20
10 240 100 20
10 210 100 20];
vPosEdit = [110 420 100 20
110 390 100 20
110 360 100 20
110 330 100 20
110 300 100 20
110 270 100 20
110 240 100 20
110 210 100 20];
defaultVals = [4;2048;0.3;100;150;4;5;250];
% ==================================================
% Define GUI --------------------------------------------------------------
h.fig = figure('Position',[250 200 800 450],...
'Color',[0.8 0.8 0.8]...
); %, 'MenuBar', 'None');
% ==================================================
% Add text and edit boxes -------------------------------------------------
for c = 1:length(vNames)
h.([vNames{c},'Text']) = uicontrol('Style', 'text',...
'Position', vPosText(c,:),...
'String',vNames{c},...
'HorizontalAlignment','Left',...
'BackgroundColor',[0.8 0.8 0.8]...
);
h.([vNames{c},'Edit']) = uicontrol('Style','edit',...
'Position',vPosEdit(c,:),...
'HorizontalAlignment','Left',...
'BackgroundColor',[1 1 1],...
'String',defaultVals(c)...
);
end
% ==================================================
% Add axes ----------------------------------------------------------------
h.dataPanel = uipanel('Parent',h.fig,...
'Position',[220 420 250 250]...
);
h.dataFig = axes('Parent',h.dataPanel...
);
axes(h.dataFig)
% figure
ezplot('y=x^2+5');
% ==================================================
% Add Pushbutton ----------------------------------------------------------
h.loadButton = uicontrol('Style','pushButton',...
'Position',[60 170 100 30],...
'String','Load Data');
set(h.loadButton,'callback',{@loadData,h,vNames});
% ==================================================
%%%%%%%%%%%% END simulateData %%%%%%%%%%%%%%%%%%
function h = loadData(hObject,eventdata,h,vNames)
vals = nan(length(vNames),1);
for c = 1:length(vNames)
vals(c) = str2double(get(h.([vNames{c},'Edit']),'String'));
end
sum(vals)
I've tried several variations on this code, but just can't get it to show. I could really use some help asap.
Many thanks
|