MATLAB Answers


Save a file inside a subfolder of a folder

Asked by Tiago Dias on 11 Feb 2019
Latest activity Commented on by Tiago Dias on 11 Feb 2019
Accepted Answer by Jan
In my directory I want to be able to creade a Folder, call a function do perform some calculations, and the results of those calculation i want to save in a subfolder of the folder. I am able to created the folder and subfolder, but the file is saved in my main directory, not even in Folder
Folder = 'Folder';
A = ones(5,1)*(1:5)
B = functionTiago(A,Folder);
% The function is attached
How to save B in the function file if possible inside the subfolder?
If not possible how to save B in the mfile inside the subfolder


Sign in to comment.

1 Answer

Answer by Jan
on 11 Feb 2019
 Accepted Answer

function out = functionTiago(A, Folder)
subFolder = fullfile(Folder, 'SUBFOLDER');
out = A + 5;
save(fullfile(subFolder, 'Filename'), 'out');
Use absoulte paths.

  1 Comment

thanks, perfect!

Sign in to comment.