Some folders in MATLAB installation location are reserved for MATLAB files.
If these folders are set as the current working folder in MATLAB, you will get a directory access error.
To resolve the error, please change the current folder to a writable folder such as C:\Users\<user_name>\Desktop.
This can be done in two ways:
- Using cd command from the command line (https://www.mathworks.com/help/matlab/ref/cd.html)
- Using GUI: Click on the folder-icon with green arrow on it (it has been marked with a red rectangle in the attached image) and select a writable folder such as C:\Users\<user_name>\Desktop _or _C:\Users\<user_name>\Documents.