Change a variable string to a normal variable

2 次查看(过去 30 天)
I need to change a string variable(x="Eval_E01") to a normal variable for example y=Eval_E01.
Is there a instrucction for this?
Thaks in advance
  1 个评论
Stephen23
Stephen23 2024-6-27
编辑:Stephen23 2024-6-27
"Is there a instrucction for this?"
Only if you want to force yourself into writing slow, complex, inefficient, obfuscated, buggy code:
"I need to change a string variable(x="Eval_E01") to a normal variable for example y=Eval_E01."
I doubt that you "need" to do that. In almost every case where a beginner writes that they "need" to use dynamic variable names, once they actually describe their usecase we can show them much better ways to achieve their task.
Rather than asking us about your anti-pattern approach, you should explain what your actual problem is:

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2024-6-26
Please read http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval for information about why we strongly recommend against creating variable names dynamically.

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by