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

10 vues (au cours des 30 derniers jours)
MathWorks Support Team
MathWorks Support Team le 25 Oct 2013
計算結果などから得られた数値を含めた変数名を定義する方法を教えてください。
例えば、
h=figure;
でfigure ウィンドウを新規作成した際に得られた figure のハンドル h に対して、
h=1 の場合はsample_1= …
h=2 の場合はsample_2= …
h=n の場合はsample_n= …
のように変数名を定義したいです。

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur プログラミング dans Help Center et File Exchange

Produits


Version

R2011a

Community Treasure Hunt

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

Start Hunting!