Disable Edit Text with Checkbox
1 view (last 30 days)
Show older comments
Hello Everybody, I need your Help. I build a GUI and I want to activate or deactivate a Edit Text Box with the Help of a Checkbox. The following is my Code for this Problem:
WN = get(handles.White_Noise,'Enable');
if WN == 'on'
set(handles.WN_per,'enable','on');
set_param('Physikalisches_Modell/Noise_Enable','Value',num2str(1));
else WN == 'off'
set(handles.WN_per,'enable','off');
set_param('Physikalisches_Modell/Noise_Enable','Value',num2str(0));
WN_per = 0;
end
White_Noise is the Checkbox, WN_per is the Edit Text. The Part, to activate the Edit Text Box works perfectly fine, but i cannot deactivate it with pressing it again.
There was another Topic for this Problem, where the User hat a similar Code and it worked, when he Startet the GUI with the Command Window. Unfortunatly, this is not the Solution.
Can anyone help me?
Tanks, Jan
0 Comments
Answers (1)
Adam Danz
on 26 Jul 2018
Edited: Adam Danz
on 26 Jul 2018
For both conditionals, instead of
if WN == 'on'
use
if strcmp(WN, 'on')
See comments below. You want to condition on the 'Value' property, not the 'Enable'.
See Also
Categories
Find more on Entering Commands 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!