你好我写下面的代码,似乎没问题。但是当我第一次运行它时会出现以下错误
评估timerfcn for timer'timer-1'时出现错误 参数的无效参数/对值
有时Matlab崩溃并发出内部错误。
我无法弄清楚导致此问题的问题。
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 10-Aug-2015 18:46:50
% 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)
% 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 GUI (see VARARGIN)
t = timer('ExecutionMode', 'fixedRate','Period',0.1,'TimerFcn', {@timerCallback},'UserData',hObject);
% Choose default command line output for GUI
handles.output = hObject;
handles.t=t;
start(t);
% 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 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 feature_button.
function feature_button_Callback(hObject, eventdata, handles)
% hObject handle to feature_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of feature_button
if get(hObject,'Value')==0
set(handles.table_feature,'Visible','off');
else
set(handles.table_feature,'Visible','on');
end
% --- Executes on button press in save_button.
function save_button_Callback(hObject, eventdata, handles)
% hObject handle to save_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
stop(timerfind('Name',handles.t.Name))
data=handles.old_data;
old_path=pwd;
[filename, pathname] = uiputfile(...
{'*.bin';'*.mat';'*.txt'},...
'Save as');
if(~isnumeric(filename) && ~isnumeric(pathname))
if(~isempty(strfind(filename, '.txt')))
cd(pathname);
dlmwrite(filename,data,'delimiter', ' ', 'newline', 'pc');
elseif(~isempty(strfind(filename, '.bin')))
write_bin(filename,data,pathname);
else
cd(pathname);
save(filename,'data');
end
cd(old_path);
end
start(timerfind('Name',handles.t.Name))
% --- Executes when user attempts to close figure1.
function figure1_CloseRequestFcn(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)
% Hint: delete(hObject) closes the figure
stop(timerfind('Name',handles.t.Name));
delete(timerfind('Name',handles.t.Name));
delete(hObject);
function timerCallback(hObject, eventdata)
%Workaround to make plot refresh correctly
handles=guidata(hObject.UserData);
set(handles.figure1,'HandleVisibility','on');
set(handles.axes1,'HandleVisibility','on');
%DATA from file
[features_int,features_double,ascan,old_data]=read_file;
handles.old_data=old_data;
%Ascan display
handles.current_data=ascan(1:2500,1);
%Catarata Type
handles.catarata=features_int(6,1);
%Table Values
table_data=cell(4,2);
table_data(:,1)=[cellstr('');cellstr('Tempo de Voo');cellstr('Coeficiente de Kurtosis CrP');cellstr('Coeficiente de Kurtosis CrA')];
table_data(:,2)=[cellstr('Valor');num2cell(features_double(1,1));num2cell(features_double(18,1));num2cell(features_double(17,1))];
handles.features=table_data;
set(handles.table_feature,'ColumnWidth',{200,100});
set(handles.table_feature,'Data',handles.features);
%Plot Ascan
plot(handles.axes1,handles.current_data)
box off;
hold on;
cra_x = [features_int(4,1)-1 features_int(4,1)-1 features_int(4,1)+1 features_int(4,1)+1];
cra_y = [-15000 15000 15000 -15000];
crp_x = [features_int(5,1)-1 features_int(5,1)-1 features_int(5,1)+1 features_int(5,1)+1];
crp_y = [-15000 15000 15000 -15000];
h=fill(cra_x,cra_y,'r',crp_x,crp_y,'m','Parent',handles.axes1);
set(h,'facealpha',.7);
set(h,'EdgeColor','none');
legend(h,'Cristalino Anterior','Cristalino Posterior','Location','SOUTH');
legend boxoff;
hold off;
%LED Config
if (features_int(6)==1)
set(handles.catarata_type,'String','Catarata Tipo 1');
set(handles.led,'Background','y');
elseif(features_int(6)==2)
set(handles.catarata_type,'String','Catarata Tipo 2');
set(handles.led,'Background',[1,0.6,0]);
elseif(features_int(6)==3)
set(handles.catarata_type,'String','Catarata Tipo 3');
set(handles.led,'Background','r');
else
set(handles.catarata_type,'String','Sem Catarata');
set(handles.led,'Background','g');
end
handles.t=hObject;
handles.output=handles.figure1;
guidata(hObject.UserData,handles);
提前致谢