MATLAB: How to use the exist feature with an if statement

function

exist varname gives valid output. But if(exist varname) throws an error as "Unexpected matlab expression". How to fix this?

Best Answer

if exist('VarName','var')