!----------------------------------------------------------
! uigetfile
!----------------------------------------------------------
[file_name,file_path] = uigetfile('*.txt','Select Input File');
if (file_name ~=0)
full_name=sprintf('%s%s',file_path,file_name);
fid=fopen(full_name,'rw');
data=fscanf(fid,'a %g %g %g %g ',[4,inf]);
data=data';
fclose(fid);
else
return
end
!----------------------------------------------------------
! uiputfile
!----------------------------------------------------------
[file_name,file_path] = uiputfile('*.txt','Save data As');
if (file_name ~=0)
full_name=sprintf('%s%s',file_path,file_name);
fid=fopen(full_name,'rw');
fprintf(fid,'%d %d %d \n',data' );
fclose(fid);
else
return
end
!----------------------------------------------------------
! multiple file select
!----------------------------------------------------------
[file,path] = uigetfile('*.txt','load data file','Multiselect','on');
!----------------------------------------------------------
! data in out
!----------------------------------------------------------
data=load('file_name.txt');
file_name = sprintf('%d.txt',str2double('xxxxxxx'));
t=linspace(0:100:100);
f=@(t) 10*exp(-0.25*t).*sin(t-4);
Syntax
filename = uigetfile
[FileName,PathName,FilterIndex] = uigetfile(FilterSpec)
[FileName,PathName,FilterIndex] = uigetfile(FilterSpec,DialogTitle)
[FileName,PathName,FilterIndex] = uigetfile(FilterSpec,DialogTitle,DefaultName)
[FileName,PathName,FilterIndex] = uigetfile(...,'MultiSelect',selectmode)
Description
filename = uigetfile displays a modal dialog box that lists files in the current folder and enables you to select or enter the name of a file. If the file name is valid and the file exists, uigetfile returns the file name as a string when you click Open. Otherwise uigetfile displays an appropriate error message, after which control returns to the dialog box. You can then enter another file name or click Cancel. If you click Cancel or close the dialog window, uigetfile returns 0.