How can I use a for loop to fill the 'String' property for many pop-up menus in a GUI???
2 views (last 30 days)
Show older comments
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 Comments
Answers (2)
Azzi Abdelmalek
on 31 Jul 2012
Edited: Azzi Abdelmalek
on 31 Jul 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 Comments
Walter Roberson
on 31 Jul 2012
for i = 1 : length(hpvalues)
set(handles.HighPass_CH(i), 'String', num2str(hpvalues(i)) )
end
0 Comments
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!