MATLAB: Save files using MATLAB

data importimage analysisimage processing

Hi,
I have used a function like below.
function rough1(src,des)
p = dir(fullfile(src,'*.tif'));
mkdir(des);
....
...
...
end
and in the command window i was calling this
  • src= [uigetdir('')];
  • des = uiputfile;
  • rough1(src,des)I can select any folder for processing. I can select any directory for save and can give a folder name. However; it by default saves in MATLAB. As for example if I want to save this to desktop and select it, it still saves in MATLAB.

Best Answer

  • Siam - uiputfile is used for choosing the filename and directory where you want to save the new file. If you want the path (as well as the file name) you would have to do something like
    [filename,pathname] = uiputfile;
    But since your are moving/copying multiple files, you don't need to choose a file name. So I think that you want to re-use the call to uigetdir to set the destination folder. Try the following
    srcPath = uigetdir('');
    destPath = uigetdir('');
    rough1(srcPath, destPath)
    I tried this, and was able to save all tifs from one directory to a folder on my desktop.