Use string value of variable as function output target

1 次查看(过去 30 天)
I am trying to iteratively run a function, putting the output to a variable of the form 'CMi', where 'i' is an integer. I can easily work with variables of this form by running:
>>> varName = strcat('CM',i)
I am strugling, however, to put the value 'CMi' as the output for a function. In particular:
>>> [varName1, varName2] = function(inputs)
redefines my variable names, and:
>>> [strcat('CM',ii)] = function(inputs)
redefines strcat. How can I print the string value of varName as the target output variable name for a function? Thanks in advance for your assistance!

采纳的回答

Walter Roberson
Walter Roberson 2012-5-16
  1 个评论
Brian Williams
Brian Williams 2012-5-16
Thanks Walter. The eval command works great. I'm going to take the wiki's advice and move away from such variable name construction as quickly as possible.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by