finding if a variable exists

조회 수: 251 (최근 30일)
joseph Frank
joseph Frank 2011년 6월 16일
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