Azzera filtri
Azzera filtri

How can I use a for loop to fill the 'String' property for many pop-up menus in a GUI???

2 visualizzazioni (ultimi 30 giorni)
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

Risposte (2)

Azzi Abdelmalek
Azzi Abdelmalek il 31 Lug 2012
Modificato: Azzi Abdelmalek il 31 Lug 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))

Walter Roberson
Walter Roberson il 31 Lug 2012
for i = 1 : length(hpvalues)
set(handles.HighPass_CH(i), 'String', num2str(hpvalues(i)) )
end

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by