How to want to define a matrix whose name is a value of another variable

1 Ansicht (letzte 30 Tage)
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.

Antworten (2)

Walter Roberson
Walter Roberson am 8 Apr. 2013

Iman Ansari
Iman Ansari am 8 Apr. 2013
Hi
V='abc'; u=rand(3);eval([V '=u']);
  2 Kommentare
Saurabh Srivastava
Saurabh Srivastava am 3 Jan. 2014
This does not work. Error msg (Index exceeds matrix dimensions)
Walter Roberson
Walter Roberson am 3 Jan. 2014
You might have accidentally defined "rand" or "eval" as variables.
In any case this approach is not recommended; please see the link I posted.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Clocks and Timers finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by