MATLAB: How to save all workspace variables and figures in a folder

importmakerMATLABMATLAB and Simulink Student Suitesaveworkspace

Hello there, I want to write a code which will save all workspace variables and figures in separate folders.
For example if I am currently in folder C:\Users\XXX\Documents
I want MATLAB to create a folder named 'ED' in 'Documents' and then create subfolder named '['N=',num2str(N)]' and further create two subfolders in '['N=',num2str(N)]' folder named 'Data' and 'Figures' and then save all workspace variables in folder 'Data' and figures in folder 'Figures'.
Is it possible in MATLAB?

Best Answer

You can save all variables in the current workspace by using save without specifying any variable name, although this is inadvisable outside of debugging.
Other functions you might want to look into: sprintf, mkdir, savefig, and fullfile