MATLAB: Files directory not found

dirguinotfound

GoodMorning, I ust want torun a script where it could give a value of zero if the selected directory doesn't exist.
It could be:
if dir C:\a == 'not found'
B=0
else
B=1
end
Actually i wanted an errormessage tho show up in gui, but that I can do by myself. Thanks

Best Answer

Use exist:
if exist('C:\a', 'dir')