h(i) = strcat('handles.uipanel',num2str(i)), when I use set(h(i),'Visible','ON') ,it doesn't work
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Well ,I have a for ...end
for b=1:9
h = strcat('handles.uipanel',num2str(b));
set(h,'Visible','ON');
end
Error:Error using set; Value must be a handle.
Thank you for your help!
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 24 Jan. 2013
Bearbeitet: Walter Roberson
am 24 Jan. 2013
In your situation you could use the dynamic fieldname approach.
2 Kommentare
Jan
am 24 Jan. 2013
I would even prefer not to let GUIDE create "handles.uipanel1", "handles.uipanel2", ..., but to create an array instead: "handles.uipanel(1)", etc. Then the loop can be omitted:
set(h.uipanel, 'Visible', 'ON');
But unfortunately the automatic code generation in GUIDE prefers to append the index to the name of the field. Then Walter's suggestion means:
for b = 1:9
set(handles.sprintf('uipanel%d', b), 'Visible', 'on');
end
Weitere Antworten (0)
Siehe auch
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!