please fix this problem

32 visualizaciones (últimos 30 días)
tran  duy
tran duy el 7 de Jul. de 2021
Respondida: Walter Roberson el 7 de Jul. de 2021
function varargout = cb_lm393(varargin)
% CB_LM393 MATLAB code for cb_lm393.fig
% CB_LM393, by itself, creates a new CB_LM393 or raises the existing
% singleton*.
%
% H = CB_LM393 returns the handle to a new CB_LM393 or the handle to
% the existing singleton*.
%
% CB_LM393('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in CB_LM393.M with the given input arguments.
%
% CB_LM393('Property','Value',...) creates a new CB_LM393 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before cb_lm393_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to cb_lm393_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 cb_lm393
% Last Modified by GUIDE v2.5 06-Jul-2021 21:29:17
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @cb_lm393_OpeningFcn, ...
'gui_OutputFcn', @cb_lm393_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 cb_lm393 is made visible.
function cb_lm393_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 cb_lm393 (see VARARGIN)
% Choose default command line output for cb_lm393
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes cb_lm393 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = cb_lm393_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 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)
global s ;
s = serial('COM2','BaudRate',9600);
fopen(s);
i=0;
while(i<200)
i=i+1;
nhietdo(i) = str2double(fscanf(s));
set(handles.nhietdo,'string',num2str(nhietdo(i)));
dienap(i) = str2double(fscanf(s));
set(handles.dienap,'string',num2str(dienap(i)));
drawnow;
axes(handles.axes1);
plot(nhietdo,'g.-','LineWidth',2);
grid on;
axis([0 100 0 1000]);
axes(handles.axes2);
plot(dienap,'r.-','LineWidth',2);
grid on;
axis([0 100 0 1000]);
end
set(handles.pushbutton1,'Enable','on');
set(handles.pushbutton2,'Enable','off');
% --- 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)
global s;
fclose (s);
set(handles.pushbutton1,'Enable','off');
set(handles.pushbutton2,'Enable','on');
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (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 edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (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
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (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 edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (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
function dienap_Callback(hObject, eventdata, handles)
% hObject handle to dienap (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 dienap as text
% str2double(get(hObject,'String')) returns contents of dienap as a double
% --- Executes during object creation, after setting all properties.
function dienap_CreateFcn(hObject, eventdata, handles)
% hObject handle to dienap (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
function nhietdo_Callback(hObject, eventdata, handles)
% hObject handle to nhietdo (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 nhietdo as text
% str2double(get(hObject,'String')) returns contents of nhietdo as a double
% --- Executes during object creation, after setting all properties.
function nhietdo_CreateFcn(hObject, eventdata, handles)
% hObject handle to nhietdo (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
% --- Executes during object deletion, before destroying properties.
function figure1_DeleteFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global s;
if ( strcmp(get(s,'Status'),'open'));
fclose(s);
end
delete(s);
clear(s);
  2 comentarios
Steven Lord
Steven Lord el 7 de Jul. de 2021
What is "this problem"?
  • Do you receive warning and/or error messages? If so the full and exact text of those messages (all the text displayed in orange and/or red in the Command Window) may be useful in determining what's going on and how to avoid the warning and/or error.
  • Does it do something different than what you expected? If so, what did it do and what did you expect it to do?
  • Did MATLAB crash? If so please send the crash log file (with a description of what you were running or doing in MATLAB when the crash occured) to Technical Support using the telephone icon in the upper-right corner of this page so we can investigate.
tran  duy
tran duy el 7 de Jul. de 2021
the problem:
??? Reference to non-existent field 'axes1'.
Error in ==> cb_lm393>pushbutton1_Callback at 100
axes(handles.axes1);
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> cb_lm393 at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)cb_lm393('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 7 de Jul. de 2021
Your cb_lm393.fig file does not have a graphics object with tag 'axes1' .
You can use GUIDE to create an axes with that tag, or you can modify cb_lm393_OpeningFcn to create handles.axes1 at run time.

Categorías

Más información sobre Graphics Object Properties en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2010b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by