MATLAB: Save figure as .mat to a different folder

handle2structsave figure as mat

Hi, I would like to save a figure as a mat file to a different folder other then the current folder. Simpfied code:
str = sort(get(findobj(0,'Type','figure'),'name'));
[s,v] = listdlg('PromptString','Select a file:',...
'SelectionMode','single',...
'ListString',str);
fig = handle2struct(figure(s));
save('Path to the folder',fig)
I've tried save(['Path'],fig) etc but nothing worked
Thank you

Best Answer

save('Path to the folder', 'fig')
The fig must be enclosed in quotes.
This is a frequently occurring problem, see Answers: Magic Strings, SAVE is not magic
Btw, FIG files have MAT format also, so you can store the FIG file by saveas and import it as struct by:
S = load('YourFile.fig', '-mat');