How to want to define a matrix whose name is a value of another variable
1 次查看(过去 30 天)
显示 更早的评论
I have a variable which contains some character data and now I want define a matrix with the same character data by using the variable. for example let variable V='abc' and now I want to define a matrix with name abc using variable V. The code which I am using is
V='abc'; u=rand(3); V=u;
Now I want that u should be assign to 'abc' but the above code actually redefine the variable V. Hope I have put my point.
0 个评论
回答(2 个)
Iman Ansari
2013-4-8
Hi
V='abc'; u=rand(3);eval([V '=u']);
2 个评论
Walter Roberson
2014-1-3
You might have accidentally defined "rand" or "eval" as variables.
In any case this approach is not recommended; please see the link I posted.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!