Saving data in folders

This file is for saving the results and figures generated by the matlab in different folders
Updated 3 Sep 2022

View License

% here the folder path is your directory where you want to save outputs
clear all; clc;
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;
% this i will give new name w.r.t numbering
dest_dir = "D:\folderpath" + i ;
filename = "plot"+string(i)+".png";
% saveas(fig,filename)
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);

Cite As

Sarmed Wahab (2024). Saving data in folders (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2022a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes