Display default variable in edit box that can be modified in GUI
5 views (last 30 days)
Show older comments
Hello! I have an edit box that is linked to a popmenu. For example, if I select parameter1 in the popmenu, the editbox displays a default value value1. If parameter2 is selected in the popmenu, value2 is displayed in the editbox. The unit is also displayed in another textbox as shown in the image below. I also need that all the default values in the editbox can be modified and appear in the workspace to be used later.
This is my code:
function param_menu_Callback(hObject, eventdata, handles)
global parametre
parametre=get(handles.param_menu, 'Value');
if parametre==1
set(handles.edit_vmin, 'String' , '----');
set(handles.unit_text, 'String', {''}); % sets the units in the unit_text
elseif parametre==2
set(handles.edit_vmin, 'String' , '1000'); %sets filtering values of the chosen parameter
set(handles.unit_text, 'String', {'Tours/s'}); % sets the units in the unit_text
elseif parametre==3
set(handles.edit_vmin, 'String', '100');
set(handles.unit_text, 'String', {'kW'});
elseif parametre==4
set(handles.edit_vmin, 'String', '9.5');
set(handles.unit_text, 'String', {'Tours/s'});
elseif parametre==5
set(handles.edit_vmin, 'String', '5');
set(handles.unit_text, 'String', {'m/s'});
end
function edit_vmin_Callback(hObject, eventdata, handles)
global valeur_min
valeur_min=str2double(get(handles.edit_vmin,'String'));
It gives me "value_min" in the workspace (double) (that i can use in another file).
When I change the value (remove the default value of editbox and choose another one)and start the analysis, the value goes back to the default value and not the one i've entered. I would like to be able to have a default value and to still be able to choose one. Thank you again for your time!
6 Comments
Adam
on 6 Jun 2017
Do you press enter or tab or something similar after editing the value? An edit callback won't trigger if you just type the number in. I'm not sure if it would trigger before the pushbutton callback if you move away and click on that, I assume not.
Answers (0)
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!