finding if a variable exists

256 次查看(过去 30 天)
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
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 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by