計算結果などから得ら​れた数値を含んだ変数​名を定義できますか?

8 visualizaciones (últimos 30 días)
MathWorks Support Team
MathWorks Support Team el 25 de Oct. de 2013
Respondida: MathWorks Support Team el 25 de Oct. de 2013
計算結果などから得られた数値を含めた変数名を定義する方法を教えてください。
例えば、
h=figure;
でfigure ウィンドウを新規作成した際に得られた figure のハンドル h に対して、
h=1 の場合はsample_1= …
h=2 の場合はsample_2= …
h=n の場合はsample_n= …
のように変数名を定義したいです。

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 25 de Oct. de 2013
NUM2STR 関数と EVAL 関数を使えば、計算した数値を含めた変数名を定義することが可能です。
・ サンプルコード
h=figure;
eval(['sample_',num2str(h),'=rand(1)'])

Más respuestas (0)

Categorías

Más información sobre プログラミング en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2011a

Community Treasure Hunt

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

Start Hunting!