MATLAB: How to save a string as a filename

charactersfilenamesavestring

Hi, How to save a file "with the characters of a string" as the file name? For example, I have a piece of code, which generates a sting output "case study_# " and the number (#) changes each time I feed in different inputs. I want the name of the output file to be saved, based on the string output. Thanks, Subrat

Best Answer

Maybe something like this
for number=1:10
file_name = sprintf('case study_#%d.txt',number);
save(file_name,...);
end