I think you should give writing permission to its directory. Firstly, you have to find where your matlab is located, so write "matlabroot" to matlab's command window.
It will give you something like this: '/Applications/MATLAB_R2017b.app'
Then after that open Mac OS X Command Line and change your directory into that and give writing permission to it, simply write the commands below.
sudo chmod o+rwx .
It will give you writing permission to this file.