The new Matlab versions starting in 2018 rolled out a functioo called isfolder(filename)
, which is quite handy.
But if you're using a version of Matlab before 2018a, you can still easily accomplish this task with the following code:
exist(filename,'dir')==7
How does it work?
Here, we are telling the exist function to look for the specified filename, and we are asking it to check whether it is a directory. If so, it will return the integer 7. This handy function will check whether the specified filename is one of several options, and you can read more about it here if you're interested.
Share