Warning when passing arguments to a GUIDE GUI - matlab

I am trying to pass arguments to a GUIDE generated GUI. This works but throws a Warning.
inputTest('Passed In String')
Warning: The input to STR2FUNC "Passed In String" is not a valid
function name. This will generate an error in a future release.
I know I have passed arguments to GUIDE GUIs in the past and I don't recall ever seeing this warning message before. However, I am relatively new to Matlab 2016b so something may have changed that I am not aware of. I didn't find anything in the documentation.
The warning occurs in the "initialization code - DO NOT EDIT" auto generated section and only happens when passing in an optional argument.
Is this a bug in 2016b or have I missed something?
Minimal Example below. It is a simple GUI with only a single Edit box.
function varargout = inputTest(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', #inputTest_OpeningFcn, ...
'gui_OutputFcn', #inputTest_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1}); % WARNING OCCURS HERE
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
function inputTest_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
% Fill the box if the string is passed in.
if nargin == 4
handles.edit1.String = varargin{1};
else
handles.edit1.String = 'Nothing Passed In';
end
guidata(hObject, handles);
function varargout = inputTest_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function edit1_Callback(hObject, eventdata, handles)
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

The default GUIDE GUI behavior is explained in the autogenerated inline documentation:
% ASDF MATLAB code for asdf.fig
% ASDF, by itself, creates a new ASDF or raises the existing
% singleton*.
%
% H = ASDF returns the handle to a new ASDF or the handle to
% the existing singleton*.
%
% ASDF('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ASDF.M with the given input arguments.
%
% ASDF('Property','Value',...) creates a new ASDF or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before asdf_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to asdf_OpeningFcn via varargin.
The syntax you're attempting to use is the syntax reserved for calling callbacks that are local to your GUI, which is why it's using a str2func call on the first input. Either remove the str2func call or change your input syntax to accept a separate output than what GUIDE is designed for.

Related

plotting sound signal using matlab and gui

when i'm running this code it gave me nothing but the following error
matlab.graphics.internal.figfile.FigFile/read>#(hObject,eventdata)untitled('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
here's my code
function varargout = untitled(varargin)
% UNTITLED MATLAB code for untitled.fig
% UNTITLED, by itself, creates a new UNTITLED or raises the existing
% singleton*.
%
% H = UNTITLED returns the handle to a new UNTITLED or the handle to
% the existing singleton*.
%
% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED.M with the given input arguments.
%
% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help untitled
% Last Modified by GUIDE v2.5 16-Dec-2016 17:10:11
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', #untitled_OpeningFcn, ...
'gui_OutputFcn', #untitled_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before untitled is made visible.
function untitled_OpeningFcn(hObject, ~, 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
bushbutton1()
bushbutton2()
% Update handles structure
handles.output = hObject;
guidata(hObject, handles);
% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled_OutputFcn(~, ~, handles)
varargout{1} = handles.output;
% --- Executes on button press in bushbutton1.
function bushbutton1_Callback(hobject,eventdata,handles)
global speech
x = audiorecorder(16000,16,1);
recordblocking(x,3);
speech = getaudiodata(x,'double');
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes1)
plot(handles.speech)
is there any suggestions, thanks.
You didn't save speech into the handles struct. You need to do so using guidata
function bushbutton1_Callback(hobject,eventdata,handles)
x = audiorecorder(16000,16,1);
recordblocking(x,3);
handles.speech = getaudiodata(x,'double');
% Save the updated handles struct
guidata(hobject, handles);
end
function pushbutton2_Callback(hObject, eventdata, handles)
axes(handles.axes1)
plot(handles.speech)
end
or just use speech since you've already defined it as a global variable. Note that this is less preferable since the usage of global variables can lead to many issues.
function pushbutton2_Callback(hObject, eventdata, handles)
gloabl speech
plot(speech)
end

Storing data in nested functions in GUIDE, Matlab

I'm trying to create a simple gui in matlab and have some problems. The main idea of this simplified program is that I have a slider, it determines the frequency of a sine wave. Two plots show the resulting signal. A high res in 44100 Hz, and a low res in 100 Hz. Another slider determines the length of the signal being plotted (also this measured in Hz). The original program has quite a few more sliders to add more frequencies, but since I didn't think it was important I tried to scale it back for this question. The resulting code is still quite large, sorry for that.
My problem is it doesn't always update, and I get error messages. I try to store everything in handles, since I think this is how you're supposed to do it. handles.lowresx contains the low res time scale, handles.highresx contains the high res time scale. A temporary lowresy and highresy is then created in the function calcandplot(handles). Every time the time interval slider is moved, the function recalcx(hObject, newhz, handles) is called from the slider movement callback and a new lowresx and lowresy is calculated. It is then stored in guidata(hObject,handles) (I would hope) and these are used to calculate new lowresy and highresy for plotting. It doesn't seem to be stored though.
I'm not sure how to save the data now when it is a nested function inside the callback function. Am I supposed to call guidata(hObject, handles) all the way up in the call stack, meaning I have to pass down hObject as an argument to every function? Or only in the most inner function? I've tried both and none really work. And is it enough to just calculate lowresy and highresy and plot them, if I don't need them later, or should I save them in handles too, to make everything work right?
Do I have to call guidata(handles) after calling set(handles.intervaltext, 'String', num2str(val)) or does it update itself?
And I have a question about handles. The way I understand it a copy is created and passed down every time a function is called. Does this pose some kind of restrictions on how big data structures you can save there for it to be efficient? If a copy is created for every gui component when some kind of event is called on it (mouseover, key pressed etc) I can certainly see how things can get sluggish. Any tips for how to handle this?
Error message:
Reference to non-existent field 'lowresx'.
Error in gui>calcandplot (line 85)
lowresy = wave(handles.lowresx, handles.freq1);
Error in gui>intervalslider_Callback (line 106)
calcandplot(handles);
Code:
function varargout = gui(varargin)
% GUI MATLAB code for gui.fig
% GUI, by itself, creates a new GUI or raises the existing
% singleton*.
%
% H = GUI returns the handle to a new GUI or the handle to
% the existing singleton*.
%
% GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI.M with the given input arguments.
%
% GUI('Property','Value',...) creates a new GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before gui_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to gui_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help gui
% Last Modified by GUIDE v2.5 12-Oct-2016 14:18:38
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', #gui_OpeningFcn, ...
'gui_OutputFcn', #gui_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before gui is made visible.
function gui_OpeningFcn(hObject, eventdata, handles, varargin)
handles.freq1 = 0;
handles.lowsr = 1000;
handles.sr = 44100;
handles.lenhz = 220;
recalcx(hObject, handles.lenhz, handles);
'recalculated'
% Choose default command line output for gui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes gui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = gui_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
val = get(hObject,'Value');
handles.freq1 = val;
guidata(hObject, handles);
set(handles.text1, 'String', num2str(val));
calcandplot(handles);
% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
function calcandplot(handles)
lowresy = wave(handles.lowresx, handles.freq1);
highresy = wave(handles.highresx, handles.freq1);
axes(handles.axes1);
plot(handles.lowresx,lowresy, 'o');
axes(handles.axes2);
plot(handles.highresx,highresy, 'o');
function y = wave(x, freq1)
% x in sec
y = sin(x*freq1);
% --- Executes on slider movement.
function intervalslider_Callback(hObject, eventdata, handles)
val = get(hObject,'Value');
recalcx(hObject, val, handles);
strcat('val is now ', num2str(val))
strcat('handles.lenhz is now', num2str(handles.lenhz))
guidata(hObject, handles);
set(handles.intervaltext, 'String', num2str(val));
handles
calcandplot(handles);
% --- Executes during object creation, after setting all properties.
function intervalslider_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
function recalcx(hObject, newhz, handles)
handles.lenhz = newhz;
handles.lowresx = (0:1/handles.lowsr:(2*pi)/handles.lenhz)';
handles.highresx = (0:1/handles.sr:(2*pi)/handles.lenhz)';
strcat('inside handles is', num2str(handles.lenhz))
guidata(hObject, handles);
strcat('inside handles again is', num2str(handles.lenhz))
The issue is that within recalcx, you are modifying handles by adding the field lowresx. You (correctly) save this to the guidata using guidata(hObject, handles).
The issue is that in the calling function (gui_OpeningFcn), you then save a different handles struct that doesn't have those fields to the guidata since the modifications to the handles structure within recalcx aren't propagated back to the calling function.
It is this handles struct without those fields that is then passed around your GUI and causes the error you're seeing.
One option for how to fix this would be to have recalcx return the modified handles struct
function handles = recalcx(hObject, newhz, handles)
handles.lenhz = newhz;
handles.lowresx = (0:1/handles.lowsr:(2*pi)/handles.lenhz)';
handles.highresx = (0:1/handles.sr:(2*pi)/handles.lenhz)';
strcat('inside handles is', num2str(handles.lenhz))
guidata(hObject, handles);
strcat('inside handles again is', num2str(handles.lenhz))
end
And then the calling function can have an updated version
function gui_OpeningFcn(hObject, eventdata, handles, varargin)
handles.freq1 = 0;
handles.lowsr = 1000;
handles.sr = 44100;
handles.lenhz = 220;
handles = recalcx(hObject, handles.lenhz, handles);
% Choose default command line output for gui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);

Passing outside variables to MATLAB GUIDE

My program loads data from a file and produces a graph, the user clicks on an area of interest and then analysis is done and a new graph is produced. The program continues asking the user to click on the image until the user presses e to exit the program.
I want the graph that is produced to be a GUI that takes data from my program but I seem to have trouble transferring that data into the GUI function. Here is a quick example of what my program looks like:
load(data)
plot(x,y)
while 1%so that it continues asking for user interaction
figure(1)
'click on the point you want or press e to exit'
[x1,y1,key]=ginput(1)
f=score(x1,y1)
%the above is a different function that gives us the data that I want to graph,
%that are called xf,yf
%GUI plot
figure(1)
test_gui(xf,yf)
if (key == 'e')
display('End')
break;
else
display('next point')
end
end
My test_gui.m looks like this:
function varargout = test_gui(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', #test_gui_OpeningFcn, ...
'gui_OutputFcn', #test_gui_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before fft_guide is made visible.
function test_gui_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for test_gui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes test_gui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = test_gui_OutputFcn(hObject, eventdata, handles)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
plot (xf,yf)
The problem is that when I click on the "Push" button, it does not graph anything so there must be something wrong in the way I pass the xf, yf variables. I was wondering if anyone has any ideas about what I am doing wrong, I have not used GUIDE before and it seems I'm lost.
From the looks of your code, xf and yf are never defined, only f (the result of score). So that could be why you can't see any plots.
Supposing that score dumps xf and yf into the workspace, you must first define them from varargin and then pass them to the callback function using handles, as Werner commented.
% --- Executes just before fft_guide is made visible.
function test_gui_OpeningFcn(hObject, eventdata, handles, varargin)
xf = varargin{0}; yf = varargin{1}; % Get xf and yf from input
handles.xf = xf; handles.yf = yf; % Put the values in handles
guidata(hObject,handles); % Save handles so you can use it anywhere in the GUI
And in the callback:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
plot (handles.xf,handles.yf)
I believe this should work, supposing xf and yf are being correctly define before being passed to the GUI function.

GUI help MATLAB

So after completing some basic image processing programs, including inversion/mirroring/filtering etc, I want to create a GUI that includes buttons that could carry out each of these programs on an image that would be opened. After fiddling around with 'guide' I have gotten a bit lost.
All of these callbacks/createfcn/buttondownfcn have me a little bit confused, and I cant seem to get my syntax correct.
Ive tried various methods to make a button correspond to the push of a button including
function X %just adding the name of a function after the green comment lines describing the three variables
But that does not yield any results. My question is, how would I program a button to correspond with a function that I have previously created. Am I simply missing a certain function or am I not understanding some broader concept?
Sorry if the question is a bit vague, my knowledge on GUI's is rather small.
When you create a uiobject in guide, a callback function will be automatically generated in the corresponding m-file. Place your function call within that callback, and it will be executed when the button is pressed.
If you have other inputs, such as a text box or a select box, you can access them from the callback to read in the variable input.
For example, if you've got a textbox with the tag textbox1, and a function that you want to use the texbox content for, myfun, place the following under your button's callback function:
str = get(handles.textbox1,'String');
myfun(str);
OK, I generally don't care for GUIDE GUI's, but here's a really simple example:
function varargout = untitled(varargin)
% UNTITLED M-file for untitled.fig
% UNTITLED, by itself, creates a new UNTITLED or raises the existing
% singleton*.
%
% H = UNTITLED returns the handle to a new UNTITLED or the handle to
% the existing singleton*.
%
% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED.M with the given input arguments.
%
% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help untitled
% Last Modified by GUIDE v2.5 18-Jun-2013 08:52:25
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', #untitled_OpeningFcn, ...
'gui_OutputFcn', #untitled_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
end
% --- Executes just before untitled is made visible.
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);
% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);
end
% --- Outputs from this function are returned to the command line.
function varargout = untitled_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% get a handle to the text field
textDisp = get(handles.text1,'String');
if( strcmp(textDisp{1},'Static Text' ) )
set(handles.text1,'String',{'Checkout my new text'});
elseif( strcmp(textDisp{1},'Checkout my new text') )
set(handles.text1,'String',{'Clicked it 1 time'})
else
dd = sscanf(textDisp{1},'Clicked it %d time');
dd = dd + 1;
set(handles.text1,'String',{['Clicked it ' num2str(dd) ' time']})
end
end
It's going to run off a really simple figure that looks like this:
Every time the button is pushed, it calls the pushbutton1_Callback with the hObject, handle of the object that caused the callback, the button, eventdata, in this case it'll be empty, and the handles structure which has a handle to everything in the GUI in this case. Merely do your image processing in the callback function or whatever and it should allow you to get where you're going. HTH!

Remnants of MATLAB Popup Selection Example Stay There

I am still learning my way around MATLAB's gui. I used one of GUIDE's templates, precisely the GUI with Axes and Menu.
This generates two files: GUIFigure.m and GUIFigure.fig
At first, I deleted the line that gives labels to the popup menu which goes along the following lines:
function popupmenu1_CreateFcn(hObject, eventdata, handles)
set(hObject, 'String', {'old text 1', 'old text 2');
When I replaced the text inside the curly brackets with my own text, it worked fine. When I replaced it with a cell variable and used incorrect syntax, it would give me an error, which is understandable, but the figure would still pop up with the old text.
Another similar issue is that the example already has a plot with axes. Now I deleted the axes from the .fig file, and I also deleted their code in the .m file. However when I run the gui function, the axes still show up with the plot, although I've even deleted the code that generates the data for the plot!
Any explanation/tips as to what is going on would be appreciated.
function varargout = FIAFigure(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', #FIAFigure_OpeningFcn, ...
'gui_OutputFcn', #FIAFigure_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before FIAFigure is made visible.
function FIAFigure_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for FIAFigure
handles.output = hObject;
handles.dataSetsCell = varargin{1};
handles.categoryNames = varargin{2};
% Update handles structure
guidata(hObject, handles);
if strcmp(get(hObject,'Visible'),'off')
plot(rand(5));
end
% --- Outputs from this function are returned to the command line.
function varargout = FIAFigure_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
t = uitable(handles.uitable1);
cla;
popup_sel_index = get(handles.popupmenu1, 'Value');
set(t,'Data',magic(popup_sel_index))
% --------------------------------------------------------------------
function FileMenu_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function OpenMenuItem_Callback(hObject, eventdata, handles)
file = uigetfile('*.fig');
if ~isequal(file, 0)
open(file);
end
% --------------------------------------------------------------------
function PrintMenuItem_Callback(hObject, eventdata, handles)
printdlg(handles.figure1)
% --------------------------------------------------------------------
function CloseMenuItem_Callback(hObject, eventdata, handles)
selection = questdlg(['Close ' get(handles.figure1,'Name') '?'],...
['Close ' get(handles.figure1,'Name') '...'],...
'Yes','No','Yes');
if strcmp(selection,'No')
return;
end
delete(handles.figure1)
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
set(hObject, 'String', {handles.categoryNames{1:end}});
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes during object creation, after setting all properties.
function uitable1_CreateFcn(hObject, eventdata, handles)