How to save the output in a certain folder?
795 views (last 30 days)
Chad Greene on 26 Jun 2016
To save the variables x and y to a file called "myfile.mat" in a folder called "myfolder" try this:
x = 1:360;
y = sind(x);
If the folder is not a subfolder of your current directory, you can specify the full filepath to that folder instead of "myfolder/..."
Sarmed Wahab on 3 Sep 2022
Moved: Stephen23 on 3 Sep 2022
I am posting this for people finding relative answer.
for i = 1:5
x = rand(10,1) ;
y = 3*x + i^2 ;
plot(x,y,"bo"); hold on;
a = plot(x,y) ; hold off;
dest_dir = "C:\folder\PROJECT DATA\figure" + i ;
filename = "plot"+string(i)+".png";
fig_file = fullfile(dest_dir , filename)
%saveas(a, filename) %save the file there directory
saveas( a, fig_file)
result = "results"+i;
matfile = fullfile(dest_dir, result);