MATLAB: Does printing a figure to a file cause a warning about “File not found or permission denied” in MATLAB 7.0.4 (R14SP2)

.jpgfiguresinitialinitiallyjpegMATLABsavetif

I attempt to print a figure to a file using the following command:
print -djpeg \rew\Projects\Fullwave\qutest3.jpg
I obtain the tollowing warning message the first time I attempt to print:
Warning: File not found or permission denied
> In graphics\private\name at 90
In print at 202
The figure is printed to a JPG file as expected. If I repeat the command, the figure is printed with no warnings.

Best Answer

This warning message can appear when the user does not have delete permissions for the current working directory.
When you print to a file, MATLAB verifies that it can write to the specified location. If the specified file does not already exist, it is created temporarily as part of this process and then deleted before printing to the specified location.
To work around this issue, make sure that you have delete permission to the directory that you are working on. You can do so by running MATLAB in Administrator mode (with administrator rights). This can be done by right-clicking the MATLAB shortcut on Windows and clicking 'Run as Administrator'. On Mac and Linux machines, usually, typing the following at a terminal window would resolve this issue:
sudo matlab