setting handles for an array of pushbuttons (i.e. pushbutton(i))
Ältere Kommentare anzeigen
i want to set handles for an array of pushbuttons starting from pushbutton1 to pushbutton10 (i.e. pushbutton(i)), is this possible in Matlab? for example a code look like
for i=1:10
set(handles.pushbuttton(i),'String','i')
end
thanks..
3 Kommentare
Daniel Shub
am 12 Mär. 2012
What happens when you run the code and what do you expect to get? You probably want to replace 'i' with num2str(i).
kaan yilmaz
am 12 Mär. 2012
Jan
am 12 Mär. 2012
Your code sets the string of the buttons to 'i'. Your comment means, that you want to get the BackgroundColor. Both are different problems.
Akzeptierte Antwort
Weitere Antworten (2)
kaan yilmaz
am 12 Mär. 2012
0 Stimmen
Jan
am 12 Mär. 2012
This will get the background color of all buttons as a cell:
state.allpushbuttonBG = get([handles.pushbutton],'Backgroundcolor');
and to set it later:
set([handles.pushbutton], 'Backgroundcolor', state.allpushbuttonBG);
I cannot try it currently, perhaps you need addition curly braces:
set([handles.pushbutton], {'Backgroundcolor'}, state.allpushbuttonBG);
Kategorien
Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!