1、在GUI上建立壹個按鈕Button
2、為按鈕Button添加單擊事件,用來導入txt文件
3、在單擊事件中設置要打開的文件地址,以及讀取操作設置
4、具體代碼如下
function?filename=OnFileOpen()%UNTITLED1?Summary?of?this?function?goes?here
%?Detailed?explanation?goes?here
[filename,filepath]=uigetfile('*.txt','打開文件');%gui中打開文件
%file=[filename,filepath];
%fid=fopen(file,'rt');%read?txt
filep=strcat(filepath,filename);
%filep
workImg=imread(filep);
%提取文件內容
imshow(workImg);