How can I use a for loop to fill the 'String' property for many pop-up menus in a GUI???
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Azzi Abdelmalek
2012-7-31
编辑:Azzi Abdelmalek
2012-7-31
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 个评论
Walter Roberson
2012-7-31
for i = 1 : length(hpvalues)
set(handles.HighPass_CH(i), 'String', num2str(hpvalues(i)) )
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!