How to name an array or series of arrays in a pattern?

4 Ansichten (letzte 30 Tage)
Sukumar Palo
Sukumar Palo am 10 Feb. 2011
I have around 10 variables and want to name the array according the variable.
e.g Variable 1 is '11234742' then the name will be Signal_11234742.
and when this variable comes again I should be able to put data into Signal_11234742.
How to do it.

Antworten (3)

Doug Hull
Doug Hull am 10 Feb. 2011
Please do not do this!
See this question:

Igor
Igor am 10 Feb. 2011
may be these commands give help 1) eval('...') 2) num2str
but more interesting: May one variable (allocated memory) have two names (used under 2 names)? In C/C++, as I know, this opportunity was indeed...
  2 Kommentare
Khaled Khairy
Khaled Khairy am 10 Feb. 2011
Yes. If you instantiate an object of a class that is derived from matlab's handle class.
Igor
Igor am 31 Mär. 2011
please, give simple example... in code

Melden Sie sich an, um zu kommentieren.


Vieniava
Vieniava am 10 Feb. 2011
var1=11234742;
prefix='Signal_';
eval([prefix num2str(var1) '=' num2str(var1)]);
  1 Kommentar
Oleg Komarov
Oleg Komarov am 10 Feb. 2011
I would in general avoid this practice and use instead: Signal.s11234742 = variable

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by