Saving outputs to different folder than m-file.
425 views (last 30 days)
I have a script that I use on many different files saved in different folders. All of the files I want to keep separate I keep in different folders. I use the 'save' and 'saveas' functions in my script to keep my results. I have only one version of the script at a time, and change the inputs as appropriate for different data sets.
I would like to have the saved files to be save in the same folder I am pulling the inputs from, instead of the folder I have the m-file saved in. At this point I have not been able to successfully do this.
Matt Kindig on 28 Jun 2013
%get the directory of your input files:
pathname = fileparts('/input/file');
%use that when you save
matfile = fullfile(pathname, 'output.mat');
figfile = fullfile(pathname, 'output.fig');
More Answers (2)
Thank you, this will help you to create a new folder and save the outcome into the new folder
%make a new directory for each file
% get the new path
% make a mfile in new path
matfile = fullfile(FolderDestination, 'output.mat');
% add variables into that m file