Reputation: 75
I have the below code:
for p = 1:numel(C)
filename = C{p}{1,2};
if ~isempty(filename{:})
sprintf('%s.xlsx',filename{:})
writetable(C{p},sprintf('%s.xlsx',filename{:}))
end
end
I want to save all excel files generated in this code to "C:\AZAR"
instead of the current folder. I know I must use fullfile
and add a path to the filename but since I'm not really familiar with Matlab codes I didn't how to do it.
Upvotes: 0
Views: 121
Reputation: 466
Your guess of using fullfile
is correct. Within the if/end
block build the file name including the directory more or less as follows:
fname = fullfile('C:\', 'AZAR', sprintf('%s.xlsx',filename{:});
writetable(C{p},fname);
HTH
Upvotes: 1