I'm trying to use the 'exist' function to check whether a certain variable has been read in from a .csv file, as the existence of that variable defines the direction the rest of the code should take. This is what I have boils down to:
if exist('DATA.processedData.VTI_EX1048_09_CJC09', 'var') CJCConfirm = 'Yes';else CJCConfirm = 'No';end
(For reasons out of my control, the return has to be 'yes' or 'no'). However, even when running a data set where I know that DATA.processedData.VTI_EX1048_09_CJC09 exists (confirmed by putting it into the command window and seeing it returns a value), this:
exist DATA.processedData.VTI_EX1048_09_CJC09
still returns a 0. I've checked, and the exist function works fine with other variables in my workspace.
What do I need to do differently?
Best Answer