MATLAB: Assigning input string as variable name

inputstringvariable declaration

Hi everyone, I have a quick question. I would like to ask the user to input the name of a variable and then use that string as a new variable name. For example, say I have the value [0 1 2 3 4]. I want to ask the user to give the name he would like to that variable.
So, for example:
x = input('Enter the name of the new variable: ') Say the user enters: new_var
I want:
new_var = [0 1 2 3 4]
Can someone explain how to do this?
Thanks for the help

Best Answer

This method will be insecure: Imagine the users selects a name, which is already used in your program. Then there is no way to avoid a crash reliably.
Another problem will be evil users, who type:
"system('format C:); y"
Then eval will assign y after it has crashed your computer. I admit, this will not be the standard case. But there are a lot of possible problems, which are less brute.