|
"Andy " <theorigamist@gmail.com> wrote in message <h6k5ce$688$1@fred.mathworks.com>...
> "Clay Ross" <clayton.e.ross@gmail.com> wrote in message <h6k3ti$1a1$1@fred.mathworks.com>...
> > Hello.
> >
> > If I have an array of 1:n, how can I construct a pop-up menu with selections of 1:n? The user will be responsible for determining the value of "n." I just learned how to program GUI's in MATLAB today, so hopefully this isn't hard to do.
> >
> > Thanks!
> >
> > Clay
>
> % here is an example
That is perfect! Thanks a lot Andy!
>
> function testgui
>
> f=figure;
>
> edit1=uicontrol('Parent',f,...
> 'Style','edit',...
> 'Units','normalized',...
> 'Position',[.2 .6 .2 .1],...
> 'Callback',{@edit1_Callback});
>
> pop1=uicontrol('Parent',f,...
> 'Style','popupmenu',...
> 'Units','normalized',...
> 'Position',[.2 .2 .2 .1],...
> 'String','Enter a number');
>
> function edit1_Callback(src,eventdata)
> n=get(edit1,'String');
> n=str2double(n);
> set(pop1,'String',num2cell(1:n)');
> end
>
> end
>
> % Also see the following for lots of answers to common questions about GUIs:
> % http://www.mathworks.com/matlabcentral/fileexchange/24861
|