GUI_Mainfcn Error in Matlab
古いコメントを表示
Hey I have an issue here, I have already tried to solve this by searching from the previous issues answer but still cant resolve this. This is the code
function varargout = BrightnessMeasurement(varargin)
% BRIGHTNESSMEASUREMENT MATLAB code for BrightnessMeasurement.fig
% BRIGHTNESSMEASUREMENT, by itself, creates a new BRIGHTNESSMEASUREMENT or raises the existing
% singleton*.
%
% H = BRIGHTNESSMEASUREMENT returns the handle to a new BRIGHTNESSMEASUREMENT or the handle to
% the existing singleton*.
%
% BRIGHTNESSMEASUREMENT('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in BRIGHTNESSMEASUREMENT.M with the given input arguments.
%
% BRIGHTNESSMEASUREMENT('Property','Value',...) creates a new BRIGHTNESSMEASUREMENT or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before BrightnessMeasurement_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to BrightnessMeasurement_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 BrightnessMeasurement
% Last Modified by GUIDE v2.5 01-Jan-2021 15:39:29
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @BrightnessMeasurement_OpeningFcn, ...
'gui_OutputFcn', @BrightnessMeasurement_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 BrightnessMeasurement is made visible.
function BrightnessMeasurement_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 BrightnessMeasurement (see VARARGIN)
% Choose default command line output for BrightnessMeasurement
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes BrightnessMeasurement wait for user response (see UIRESUME)
% uiwait(handles.figure1);
delete (instrfind({'Port'}, {'COM11'}));
clear a;
global a;
a = arduino ('COM11');
a.readDigitalPin (8, 'output');
% --- Outputs from this function are returned to the command line.
function varargout = BrightnessMeasurement_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;
% --- Executes on button press in turn_on_button.
function turn_on_button_Callback(hObject, eventdata, handles)
% hObject handle to turn_on_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global a;
a.writeDigitalPin (8,1);
% --- Executes on button press in turn_off_button.
function turn_off_button_Callback(hObject, eventdata, handles)
% hObject handle to turn_off_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a.writeDigitalPin (8,0)
% --- Executes on button press in read_button.
function read_button_Callback(hObject, eventdata, handles)
% hObject handle to read_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global a k;
x = 0;
for k = 1:1:handles.XSamples
b = a.analogRead (0);
x = [x,b];
plot(x,'LineWidth',2); grip on;
axis ([0 handles.xSamples 0 500]);
pause (0.01);
end
function sample_data_Callback(hObject, eventdata, handles)
% hObject handle to sample_data (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 sample_data as text
% str2double(get(hObject,'String')) returns contents of sample_data as a double
handles.data1 = get(hObject, 'stirng');
handles.xSamples = str2double (handles.data1);
guidata (hObject, handles);
% --- Executes during object creation, after setting all properties.
function sample_data_CreateFcn(hObject, eventdata, handles)
% hObject handle to sample_data (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
and this is the error warning
Error in gui_mainfcn (line 220)
feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});
Error in BrightnessMeasurement (line 42)
gui_mainfcn(gui_State, varargin{:});
please help
4 件のコメント
Karim Khalid
2021 年 10 月 7 日
Were you able to solve this issue?
Ashutosh Bajpai
2022 年 8 月 23 日
Is the issue resolved?
Radu-Nicolae
2022 年 9 月 21 日
I have the same issue
Walter Roberson
2022 年 9 月 21 日
That would not be the entire error message; we need the entire error message.
We would not be able to test the code without the associated .fig file.
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Graphics Object Properties についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!