我使用GUIDE Matlab创建了一个GUI,它在GUI启动时读取文件,在读取文件中的数据后,GUI根据数据进行操作。
这些GUI应该是程序的前端,每5毫秒更改一次GUI读取的文件。所以我想要达到的是一个更新自己读取该文件的GUI。我为启动GUI所做的代码如下。
% --- 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)
%DATA from file
[features_int,features_double,ascan]=read_file;
%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(19,1));num2cell(features_double(18,1))];
handles.features=table_data;
set(handles.table_feature,'ColumnWidth',{200,100});
set(handles.table_feature,'Data',handles.features);
%Plot Ascan
plot(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');
set(h,'facealpha',.7);
set(h,'EdgeColor','none');
legend(h,'Cristalino Anterior','Cristalino Posterior','Location','SOUTH');
legend boxoff;
%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
% Choose default command line output for GUI
handles.output = hObject;
% Update handles structure
guidata(hObject,handles);
提前致谢