finding if a variable exists

255 visualizzazioni (ultimi 30 giorni)
joseph Frank
joseph Frank il 16 Giu 2011
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

Risposta accettata

Walter Roberson
Walter Roberson il 16 Giu 2011
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

Più risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by