Hi,
I am trying to retrieve the values that will be in the user input boxes and also that of the list box, my code so far is:
function BevelMenu()
figBevel = figure('Color',[0.925 0.914 0.847],... % This just changes the colour of the background in the window
'Visible','off',... %Makes the window invisible
'Resize','on', ... %Allows to resize the window
'Number','off', ... %Gets rid of number in heading
'unit','normalized', ...
'Name','Positioning of a Bevel Gear', ...
'Units', 'pixels');
movegui(figBevel,'center') %Centres it
set(figBevel,'Visible','on') %Makes visible after being centered
% image = uicontrol(figBevel,...
% 'Visible','on','01.bmp')
% To display Shaft 1 Frame:
shaft_text = uicontrol(figBevel, ...
'style','text', ...
'unit','normalized', ...
'BackgroundColor',[0.925 0.914 0.847], ...
'ForegroundColor','blue', ...
'FontSize',10, ...
'position',[0.3 0.88 0.2 0.045], ...
'string','Shaft 1 Frame: ');
% List for Shaft 1
shaft1_list = uicontrol(figBevel, ...
'Style','listbox', ...
'Units','normalized', ...
'BackgroundColor',[1 1 1], ...
'String',{'a' 'b' 'c'},...
'tag','shaft1_value', ...
'Callback',{@listBoxCallback}, ...
'Value',1,'Position', [0.5 0.85 0.1 0.1]);
set(shaft1_list, 'listboxtop',1);
abs_text = uicontrol(figBevel, ...
'style','text', ...
'unit','normalized', ...
'BackgroundColor',[0.925 0.914 0.847], ...
'ForegroundColor','blue', ...
'FontSize',10, ...
'position',[0.23 0.75 0.35 0.05], ...
'string','C1 abscissa on shaft 1 frame: ');
abs_input = uicontrol(figBevel, ...
'style','edit', ...
'unit','normalized', ...
'BackgroundColor',[1 1 1], ...
'tag','abs_value', ...
'position',[0.57 0.76 0.05 0.05]);
abs_mm = uicontrol(figBevel, ...
'style','text', ...
'unit','normalized', ...
'BackgroundColor',[0.925 0.914 0.847], ...
'ForegroundColor','blue', ...
'FontSize',10, ...
'position',[0.64 0.75 0.04 0.05], ...
'string','mm');
pitch_text = uicontrol(figBevel, ...
'style','text', ...
'unit','normalized', ...
'BackgroundColor',[0.925 0.914 0.847], ...
'ForegroundColor','blue', ...
'FontSize',10, ...
'position',[0.125 0.65 0.22 0.05], ...
'string','Pitch diameter dP1: ');
pitch_input = uicontrol(figBevel, ...
'style','edit', ...
'unit','normalized', ...
'BackgroundColor',[1 1 1], ...
'tag','pitch_value', ...
'position',[0.36 0.66 0.05 0.05]);
pitch_mm = uicontrol(figBevel, ...
'style','text', ...
'unit','normalized', ...
'BackgroundColor',[0.925 0.914 0.847], ...
'ForegroundColor','blue', ...
'FontSize',10, ...
'position',[0.42 0.65 0.33 0.05], ...
'string','mm OR Mean diameter, dm1: ');
mean_input = uicontrol(figBevel, ...
'style','edit', ...
'unit','normalized', ...
'BackgroundColor',[1 1 1], ...
'tag','mean_value', ...
'position',[0.76 0.66 0.05 0.05]);
mean_mm = uicontrol(figBevel, ...
'style','text', ...
'unit','normalized', ...
'BackgroundColor',[0.925 0.914 0.847], ...
'ForegroundColor','blue', ...
'FontSize',10, ...
'position',[0.83 0.65 0.04 0.05], ...
'string','mm');
tooth_text = uicontrol(figBevel, ...
'style','text', ...
'unit','normalized', ...
'BackgroundColor',[0.925 0.914 0.847], ...
'ForegroundColor','blue', ...
'FontSize',10, ...
'position',[0.16 0.55 0.5 0.05], ...
'string','Tooth width, b: ');
tooth_input = uicontrol(figBevel, ...
'style','edit', ...
'unit','normalized', ...
'BackgroundColor',[1 1 1], ...
'tag','tooth_value', ...
'position',[0.5 0.56 0.05 0.05]);
tooth_mm = uicontrol(figBevel, ...
'style','text', ...
'unit','normalized', ...
'BackgroundColor',[0.925 0.914 0.847], ...
'ForegroundColor','blue', ...
'FontSize',10, ...
'position',[0.57 0.55 0.04 0.05], ...
'string','mm');
halftop1_text = uicontrol(figBevel, ...
'style','text', ...
'unit','normalized', ...
'BackgroundColor',[0.925 0.914 0.847], ...
'ForegroundColor','blue', ...
'FontSize',10, ...
'position',[0.2 0.45 0.2 0.08], ...
'string','Half top angle, delta1(degrees):');
halftop1_input = uicontrol(figBevel, ...
'style','edit', ...
'unit','normalized', ...
'BackgroundColor',[1 1 1], ...
'tag','halftop1_value', ...
'position',[0.43 0.46 0.05 0.05]);
halftop2_text = uicontrol(figBevel, ...
'style','text', ...
'unit','normalized', ...
'BackgroundColor',[0.925 0.914 0.847], ...
'ForegroundColor','blue', ...
'FontSize',10, ...
'position',[0.5 0.45 0.2 0.08], ...
'string','Half top angle, d2(degrees):');
%set(halftop2_text,'FontName','Symbol')
halftop2_input = uicontrol(figBevel, ...
'style','edit', ...
'unit','normalized', ...
'BackgroundColor',[1 1 1], ...
'tag','halftop2_value', ...
'position',[0.72 0.46 0.05 0.05]);
teeth_text = uicontrol(figBevel, ...
'style','text', ...
'unit','normalized', ...
'BackgroundColor',[0.925 0.914 0.847], ...
'ForegroundColor','blue', ...
'FontSize',10, ...
'position',[0.26 0.35 0.15 0.05], ...
'string','No. of teeth: ');
wheel1_text = uicontrol(figBevel, ...
'style','text', ...
'unit','normalized', ...
'BackgroundColor',[0.925 0.914 0.847], ...
'ForegroundColor','blue', ...
'FontSize',10, ...
'position',[0.41 0.35 0.15 0.05], ...
'string','First Wheel: ');
wheel1_input = uicontrol(figBevel, ...
'style','edit', ...
'unit','normalized', ...
'BackgroundColor',[1 1 1], ...
'tag','wheel1_value', ...
'position',[0.62 0.36 0.05 0.05]);
wheel2_text = uicontrol(figBevel, ...
'style','text', ...
'unit','normalized', ...
'BackgroundColor',[0.925 0.914 0.847], ...
'ForegroundColor','blue', ...
'FontSize',10, ...
'position',[0.4 0.27 0.2 0.05], ...
'string','Second Wheel: ');
wheel2_input = uicontrol(figBevel, ...
'style','edit', ...
'unit','normalized', ...
'BackgroundColor',[1 1 1], ...
'tag','wheel2_value', ...
'position',[0.62 0.28 0.05 0.05]);
pos_button = uicontrol(figBevel, ...
'style','push', ...
'unit','normalized', ...
'BackgroundColor',[0.925 0.914 0.847], ...
'string','Position!', ...
'Callback',{@pos_app,shaft1_list}, ...
'pos',[0.45 0.10 0.1 0.1]);
function pos_app(hObject, event) %need to get the values from all the input boxes and the value of the listbox
get(abs_input,'Tag','abs_value')
get(pitch_input,'Tag','pitch_value')
get(mean_input,'Tag','mean_value')
get(tooth_input,'Tag','tooth_value')
get(halftop1_input,'Tag'
Best Answer