MATLAB: “exist” command usage question

MATLABprogramming

Hello everyone. I wanted to know if it is possible to use a the "exist" command to check if a directory exists, nomater the username of the user eg. check=exist('C:\Users\<user_name>\—\—\—\somedit','dir') Is there a way to somehow get the username or something?

Best Answer

You can retrieve the username by using getenv('USERNAME') in MS Windows
I would suggest that you probably want to use getenv('HOMEPATH') as the base location for the directory to store files.
Related Question