How can I use a for loop to fill the 'String' property for many pop-up menus in a GUI???
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
So I am trying to use a shortcut to set the 'String' property of a pop up menu in my GUI once it opens up. Here is an example of what I am trying to do:
function untitled_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to untitled (see VARARGIN)
% Choose default command line output for untitled
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
hpvalues = [0.7 1.5 3.0 10 30 100 300 500];
for i = 1:16
set(handles.HighPass_CH(i), 'String', hpvalues)
end
%Basically I have 16 pop up menus to set the high pass filter on an amp...one button per channel. Each button is tagged HighPass_CH1, HighPass_CH2, etc..
Any ideas?
-Ian
0 commentaires
Réponses (2)
Azzi Abdelmalek
le 31 Juil 2012
Modifié(e) : Azzi Abdelmalek
le 31 Juil 2012
for i = 1:16
highpass=strcat('HighPass_CH',num2str(i)),
set(handles.(highpass), 'String', hpvalues) %hpvalues must be a string
end
%this code will set 16 popmenu named : HighPass1 HighPass2,... if your names are saved in a cell array HighPass, instead of a second line use
highpass=char(HighPass_CH(i))
0 commentaires
Walter Roberson
le 31 Juil 2012
for i = 1 : length(hpvalues)
set(handles.HighPass_CH(i), 'String', num2str(hpvalues(i)) )
end
0 commentaires
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!