Saving matlab result in different directory

25 views (last 30 days)
I want to save result of a function in a different directory. But the fne name needs to be changed as i am storing results for different cases in a for loop.
by doing this i am able to save result of different in the same directory with different names.
I would like to know if there is a way to do the same, but in a different folder.

Accepted Answer

Katie on 1 Nov 2019
Hi! You can do this by using the full file path in your file name. For example:
filename=strcat('C:\Users\katie\Documents\MATLAB\',cas{dataset});%concatenate the file path with your file name
Above, ''C:\Users\katie\Documents\MATLAB\'' is my file path.
With strcat, you can input as many strings as you would like to be concatenated. So, if you wanted to save each result into a different folder, you could set up your filename in such a way to do it:
Stephen23 on 3 Nov 2019
Edited: Stephen23 on 3 Nov 2019
To generate filenames it is recommended to use fullfile rather than concatenating strings:
filename = fullfile('C:\Users\katie\Documents\MATLAB',cas{dataset}))

Sign in to comment.

More Answers (0)




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by