MATLAB: How to save a file with the same name as the foldername

foldernamesave

This is my code inside a for loop.
cd(all_names(nn).name); %all_names.name has the name of the folder
save ('all_names(nn).name','variable')
It doesnt give me an error message, but saves my file as "all_names(nn).name" instead of the name of the folder

Best Answer

save (all_names(nn).name,'variable')
all_names(nn).name is already a string. Your usage of it in cd() is correct