我通过一些视频学习,自己编了一个gui得界面,界面上有一edit,,一个pushbutton,
我想通过点击pushbutton选择文件并将文件中的内容导入到edit中,下面是我编的代码:
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 empty_matrix
empty_matrix =[];
[filename,pathname]=uigetfile({'*.xls','excel files(*.xls)'; '*.txt','text files(*.txt)'},'选择文件');
l=length(filename);
if l<5
errordlg('请选择正确文件!');
return
end
test=filename(1,l-3:l);
switch test
case '*.xls'
str=[pathname,filename];
Determine_matrix=empty_matrix;
[Determine_matrix]=xlsread(str)