When I run the below .m file, it gives me the following error:
Error using fevalUndefined function 'frequency_axes_CreateFcn' for input arguments of type 'matlab.graphics.axis.Axes'.Error in gui_mainfcn (line 95) feval(varargin{:});Error in TestInterface (line 43) gui_mainfcn(gui_State, varargin{:});Error in @(hObject,eventdata)TestInterface('frequency_axes_CreateFcn',hObject,eventdata,guidata(hObject))
Any idea why? Here's the code from my .m:
function varargout = TestInterface(varargin)% TESTINTERFACE Application M-file for TestInterface.fig
% TESTINTERFACE, by itself, creates a new TESTINTERFACE or raises the existing
% singleton*.
%
% H = TESTINTERFACE returns the handle to a new TESTINTERFACE or the handle to
% the existing singleton*.
%% TESTINTERFACE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TESTINTERFACE.M with the given input arguments.
%% TESTINTERFACE('Property','Value',...) creates a new TESTINTERFACE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before two_axes_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to TestInterface_OpeningFcn via varargin.
%% *See GUI Options - GUI allows only one instance to run (singleton).
%% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help TestInterface
% Copyright 2001-2006 The MathWorks, Inc.
% Last Modified by GUIDE v2.5 31-May-2015 00:38:11
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @TestInterface_OpeningFcn, ... 'gui_OutputFcn', @TestInterface_OutputFcn, ... 'gui_LayoutFcn', [], ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif 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 TestInterface is made visible.
function TestInterface_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 TestInterface (see VARARGIN)
% Choose default command line output for TestInterface
handles.output = hObject;% Update handles structure
guidata(hObject, handles);% UIWAIT makes TestInterface wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = TestInterface_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;% --------------------------------------------------------------------
function plot_button_Callback(hObject, eventdata, handles, varargin)% hObject handle to plot_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)set(0,'DefaultFigureColor','White',... 'defaultaxesfontsize',8,... 'DefaultAxesFontname','Calibri',... 'DefaultTextFontName','Calibri')x = [0:20];y = [0:20];% Get user input from GUI
f1 = str2double(get(handles.f1_input,'String'));f2 = str2double(get(handles.f2_input,'String'));constant = str2double(get(handles.constant,'String'));% Calculate data
TestFormula = @(x,y)(x + y.*constant);[X,Y] = meshgrid(x,y);Z1 = TestFormula(X,Y);Z2 = TestFormula(f1,f2);% Create frequency plot in proper axes
%plot(handles.frequency_axes,f,m(1:257))
s1 = surf(X,Y,Z1)set(handles.edit5,'String',Z2)xlabel('X', 'fontweight', 'bold')ylabel('Y', 'fontweight', 'bold')%title('(A)', 'FontSize', 12, 'fontweight', 'bold')
view (135,15);yh = get(gca,'YLabel'); % Handle of the y label
set(yh, 'Units', 'Normalized')pos = get(yh, 'Position');set(yh, 'Position',pos.*[0.85,0.6,1],'Rotation',-10.9)xh = get(gca,'XLabel'); % Handle of the x label
set(xh, 'Units', 'Normalized')pos = get(xh, 'Position');set(xh, 'Position',pos.*[1,1,1],'Rotation',11.1)zlabel('Z', 'fontweight', 'bold')zh = get(gca,'ZLabel'); % Handle of the z label
set(zh, 'Units', 'Normalized')pos = get(zh, 'Position');set(zh, 'Position',pos.*[1.5,1,0],'Rotation',90)%set(handles.frequency_axes,'XMinorTick','on')
axis tightcamlightlighting phongshading interpset(s1,'FaceColor',[0 0.63 0.91], 'edgecolor',[0 0 0.4],'meshstyle','both','linewidth',.15);grid onfunction f1_input_Callback(hObject, eventdata, handles)% hObject handle to f1_input (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of f1_input as text
% str2double(get(hObject,'String')) returns contents of f1_input
% as a double
% Validate that the text in the f1 field converts to a real number
f1 = str2double(get(hObject,'String'));if isnan(f1) || ~isreal(f1) % isdouble returns NaN for non-numbers and f1 cannot be complex
% Disable the Plot button and change its string to say why
set(handles.plot_button,'String','Cannot plot f1') set(handles.plot_button,'Enable','off') % Give the edit text box focus so user can correct the error
uicontrol(hObject)else % Enable the Plot button with its original name
set(handles.plot_button,'String','Plot') set(handles.plot_button,'Enable','on')endfunction f2_input_Callback(hObject, eventdata, handles)% hObject handle to f2_input (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of f1_input as text% str2double(get(hObject,'String')) returns contents of f1_input% as a double% Validate that the text in the f2 field converts to a real number
f2 = str2double(get(hObject,'String'));if isnan(f2) ... % isdouble returns NaN for non-numbers || ~isreal(f2) % f1 should not be complex
% Disable the Plot button and change its string to say why set(handles.plot_button,'String','Cannot plot f2') set(handles.plot_button,'Enable','off') % Give the edit text box focus so user can correct the error uicontrol(hObject)else % Enable the Plot button with its original name set(handles.plot_button,'String','Plot') set(handles.plot_button,'Enable','on')endfunction edit5_Callback(hObject, eventdata, handles)% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit5 as text
% str2double(get(hObject,'String')) returns contents of edit5 as a double
% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)% hObject handle to edit5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');endfunction constant_Callback(hObject, eventdata, handles)% hObject handle to constant (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of constant as text
% str2double(get(hObject,'String')) returns contents of constant as a double
constant = str2double(get(hObject,'String'));if isnan(constant) ... % isdouble returns NaN for non-numbers || ~isreal(constant) % f1 should not be complex % Disable the Plot button and change its string to say why set(handles.plot_button,'String','Cannot plot constant') set(handles.plot_button,'Enable','off') % Give the edit text box focus so user can correct the error uicontrol(hObject)else % Enable the Plot button with its original name set(handles.plot_button,'String','Plot') set(handles.plot_button,'Enable','on')end% --- Executes during object creation, after setting all properties.function constant_CreateFcn(hObject, eventdata, handles)% hObject handle to constant (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end
Best Answer