MATLAB: How to move .mat file

filesguide

hi
i want to move my .mat files from anywhere in my pc into specified directory
like : C:\Users\Rahaf\EE208\assignment\databasedir
by using guide
how to do this ?

Best Answer

destdir = 'C:\Users\Rahaf\EE208\assignment\databasedir';
[filename, pathname] = uigetfile('*.mat', 'choose a file');
if ~ischar(filename)
return; %user cancel
end
sourcefile = fullfile(pathname, filename);
try
[success, message] = movefile(sourcefile, destdir);
if ~success
warndlg('Failed to move file "%s" to "%s" because "%s"', sourcefile, destdir, message);
return
end
catch ME
warndlg('Failed to move file "%s" to "%s" for some reason', sourcefile, destdir);
return
end
warndlg('file moved');