Filter löschen
Filter löschen

Hide push button in GUI using visible on/off

11 Ansichten (letzte 30 Tage)
Khaled Al-Faleh
Khaled Al-Faleh am 28 Apr. 2017
Kommentiert: Khaled Al-Faleh am 28 Apr. 2017
Hi guys, I'm trying to hide some push button in GUI by using
set(handles.push1,'visible','on');
so I have five push button and I want to hide some of them in loop see the code
for i=1:10
SS = ['handles.push_' num2str(i)];
set(SS,'visible','off');
end
here I want to hide the button depend on i but it gave me an error ...
  1 Kommentar
Adam
Adam am 28 Apr. 2017
If it gives you an error then tell us what the error is!! It makes it a lot easier for us to help you fix it rather than us trying to work out the error just by looking at a snippet of code.
In this case though it is clear enough to see...

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Adam
Adam am 28 Apr. 2017
Bearbeitet: Adam am 28 Apr. 2017
SS = handles.( ['push' num2str(i)] );
should work. You should use more meaningful variable names though.
Your code includes 2 mistakes - one trivial one that you include a '_' in your attempt to create the pushbutton name and one coding mistake:
SS is a string in your code. The set call requires the pushbutton object - i.e. the object stored on handles, not the name of it. You can put together a field name dynamically as I did above using ( ) syntax on the struct. The result of this will then be the pushbutton object, not a string.

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps 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