variable to output name

3 次查看(过去 30 天)
Leyon
Leyon 2013-11-1
编辑: Matt J 2013-11-1
name = 'adams'
c = 2x+4
I would like the value of "name" to be the variable for c. Therefore, instead of:
c = 2x+4
it would be:
adams = 2x+4
  5 个评论
Leyon
Leyon 2013-11-1
So the only option seems to be to create struct variables?
Thanks. i already knew this but was hoping there was another alternative so I could have a clean fieldname
Matt J
Matt J 2013-11-1
编辑:Matt J 2013-11-1
It isn't the only option, but I recommended it to you here
as the safest one. There are dangers in using assignin, eval, load, etc... to create variables inexplicitly. See, for example,

请先登录,再进行评论。

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2013-11-1
a=[2 4 5];
assignin('base','adams',a)
  1 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2013-11-1
But I don't see why it's important to change the name of your variable?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by