finding if a variable exists

I am running an if loop that creates a variable x. at a later stage if x exists I want to use to build other variables. is there any function that tells me for example if x exists x2=x*2; end

 採用された回答

Walter Roberson
Walter Roberson 2011 年 6 月 16 日

5 投票

if exist('x','var'); x2 = x*2; end
However, it is seldom a good idea to create variables on the fly. Please read this FAQ

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeIntroduction to Installation and Licensing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by