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!