# Thread: How to make generic filenames work in matlab?

1. ## How to make generic filenames work in matlab?

I've got a 1x1cell named selected_name that contains different names depending on how the function is run. So when I type selected_name in the command line it returns "selected_name = 'Peter'" for example.

What I want to do is to save the variables used in the workspace to a file named "Peter.mat". I can't get it to work. save(selected_name) does not work because it says it needs to be a string like save('somename').

How do I solve this?

2. try:
Code:
save(selected_name(1))