feval error in GUI implementation
Show older comments
I have this code that I have bult that compares a string coming over serial data to one that is stored in an excel file. A correct match makes a panel in the GUI go green, and red when they are not matched.
This is the code I have as of now:
function varargout = WorkingGUI2(varargin)
% WORKINGGUI2 MATLAB code for WorkingGUI2.fig
% WORKINGGUI2, by itself, creates a new WORKINGGUI2 or raises the existing
% singleton*.
%
% H = WORKINGGUI2 returns the handle to a new WORKINGGUI2 or the handle to
% the existing singleton*.
%
% WORKINGGUI2('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in WORKINGGUI2.M with the given input arguments.
%
% WORKINGGUI2('Property','Value',...) creates a new WORKINGGUI2 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before WorkingGUI2_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to WorkingGUI2_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 WorkingGUI2
% Last Modified by GUIDE v2.5 17-Sep-2019 15:09:28
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @WorkingGUI2_OpeningFcn, ...
'gui_OutputFcn', @WorkingGUI2_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 WorkingGUI2 is made visible.
function WorkingGUI2_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 WorkingGUI2 (see VARARGIN)
% Choose default command line output for WorkingGUI2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes WorkingGUI2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = WorkingGUI2_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;
%Begin Script
delete(instrfind('Port', 'COM3'));
tag = serial('COM3'); %check which port is used
fopen(tag);
BOX = char(zeros(2,14));
i=1;
c=0;
TrueValueData = 'C:\Mastercodes.xlsx';
[~,~,TrueValMat] = xlsread(TrueValueData); % Creates matrix filled with the correct values,
% indexed by box, which is the first row
% all proceeding rows are the master value
for i=1:9223372036854775807
if i>10 %first couple reads are filled with unicode nonsense, this skips that stage
readData = fscanf(tag);
if length(readData)>12
BOX(str2num(readData(8)),1:14)= readData(11:24); % these numbers just give us what we want;
% tags come in initially with some gobbledy-gook
end
if strcmp(TrueValMat{2,1}, BOX(1,:))
Reader1Correct;
else
Reader1Incorrect;
end
if strcmp(TrueValMat{2,2}, BOX(2,:))
Reader2Correct;
else
Reader2Incorrect;
end
if strcmp(TrueValMat{2,1}, BOX(1,:))...
&& strcmp(TrueValMat{2,2}, BOX(2,:)) == 1
break
end
end
end
% --- Executes during object creation, after setting all properties.
function uipanel1_CreateFcn(hObject, eventdata, handles1)
function Reader1Correct
set(handles1.uipanel1, 'BackgroundColor', 'g');
end
function Reader1Incorrect
set(handles1.uipanel1, 'BackgroundColor', 'r');
end
end
% hObject handle to uipanel1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes during object creation, after setting all properties.
function uipanel2_CreateFcn(hObject, eventdata, handles2)
function Reader2Correct
set(handles2.uipanel2, 'BackgroundColor', 'g');
end
function Reader2Incorrect
set(handles2.uipanel2, 'BackgroundColor', 'r');
end
end
% hObject handle to uipanel2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
end
end
end
I don't know If have correctly made or called the functions in this script. I chnaged the handles monikor becasue I got a warning that it was used multiple times ( I don't know if that was necessary). When running the program, the GUI comes up jsut as I want it, but then get this error:
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)WorkingGUI2('uipanel1_CreateFcn',hObject,eventdata,guidata(hObject))
Undefined function or variable 'WorkingGUI2_OutputFcn'.
Error in gui_mainfcn (line 264)
feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles);
Error in WorkingGUI2 (line 42)
gui_mainfcn(gui_State, varargin{:});
I don't think I need any arguments output from WorkingGUI2_Outputfcn, but I am not sure.
thanks for any help
Accepted Answer
More Answers (0)
Categories
Find more on Argument Definitions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!