Effacer les filtres
Effacer les filtres

Print function error in loop - Cannot open file:permission denied

1 vue (au cours des 30 derniers jours)
Peter
Peter le 15 Nov 2011
I have a MATLAB script which is to print to a file several figures through several iterations, adjusting the filename of each of the figures with each new iteration. The files are being created using the 'print' function, and are saved with a .pdf extension.
The script works fine until it comes across some (apparently) arbitrary and random iteration in the loop. That is, I can re-execute the script after the error and it won't report any error (let alone during the iteration in which it previously reported the error) and will output the necessary files. Perhaps it will make it through an entire set of iterations, or perhaps it reports an error at a different iteration. The point is that it appears arbitrary and random from my standpoint, and is not because of improper file name formating, broken data, etc - i.e., the problem seems to lie with the 'print.m' function.
The error is created after a call in the script to the print function, similar to this format:
print(CURRENT FIGURE HANDLE, '-dpdf', FILENAME)
where CURRENT FIGURE HANDLE is the handle to the desired figure, and FILENAME is a string containing the path, filename, and extension .pdf. It reports an error similar to this:
Error using ==> href="matlab: opentoline('C:\(MATLAB PATH HERE)\toolbox\matlab\graphics\print.m',325,0)">print at 325</a C:\(ADMINISTRATOR LOCAL SETTINGS FOLDER HERE)\Temp\tp16929d95_5949_4929_b853_6359e964bd51.ps: Cannot open file: permission denied.
Note that post-script file given in this error was created (AFAIK) by the MATLAB function 'print.m' and its name is not something I have control over.
Included at the beginning of the script is the function 'recycle off' to eliminate the sending of temporary post-script files to the recycle bin, ensuring that they're deleted permanently.
I'm running the code under the administrator on a Windows XP machine, so (AFAIK) there shouldn't be administrator privalege issues?
Here is a sample of a call to 'feature memstats' prior to the start of the script execution and prior to the error:
Physical Memory (RAM):
In Use: 846 MB (34efe000)
Free: 2697 MB (a894c000)
Total: 3544 MB (dd84a000)
Page File (Swap space):
In Use: 732 MB (2dc67000)
Free: 5647 MB (160fcf000)
Total: 6380 MB (18ec36000)
Virtual Memory (Address Space):
In Use: 802 MB (3225e000)
Free: 1245 MB (4dd82000)
Total: 2047 MB (7ffe0000)
Largest Contiguous Free Blocks:
1. [at 2d960000] 787 MB (313a0000)
2. [at 5edcc000] 82 MB ( 5234000)
3. [at 64021000] 47 MB ( 2fdf000)
4. [at 68b40000] 42 MB ( 2aa0000)
5. [at 6fea8000] 27 MB ( 1ba8000)
6. [at 73bc6000] 25 MB ( 19fa000)
7. [at 71ac7000] 21 MB ( 1539000)
8. [at 7e4a1000] 18 MB ( 124f000)
9. [at 7d49c000] 15 MB ( f74000)
10. [at 6ef2d000] 15 MB ( f73000)
======= ==========
1084 MB (43c64000)
Here is a sample of a call to 'feature memstats' after the start of the script execution and prior to the error:
Physical Memory (RAM):
In Use: 1230 MB (4ce1f000)
Free: 2314 MB (90a2b000)
Total: 3544 MB (dd84a000)
Page File (Swap space):
In Use: 1104 MB (4506b000)
Free: 5275 MB (149bcb000)
Total: 6380 MB (18ec36000)
Virtual Memory (Address Space):
In Use: 780 MB (30c8d000)
Free: 1267 MB (4f353000)
Total: 2047 MB (7ffe0000)
Largest Contiguous Free Blocks:
1. [at 2c960000] 803 MB (323a0000)
2. [at 5edcc000] 82 MB ( 5234000)
3. [at 64021000] 47 MB ( 2fdf000)
4. [at 68b40000] 34 MB ( 22d0000)
5. [at 6fea8000] 27 MB ( 1ba8000)
6. [at 73bc6000] 25 MB ( 19fa000)
7. [at 71ac7000] 21 MB ( 1539000)
8. [at 7e4a1000] 18 MB ( 124f000)
9. [at 7d49c000] 15 MB ( f74000)
10. [at 6ef2d000] 15 MB ( f73000)
======= ==========
1092 MB (44494000)
Thanks.
  3 commentaires
dpb
dpb le 22 Juil 2013
Since the question was posted almost 2 yr ago and hadn't received a response, I'd presume OP either contacted TMW technical support directly or found another route.
I see that in looking at the print.m file logic that the warning is apparently only called for a case where the function thinks there isn't an extension supplied for the filename and thus the calling syntax is potentially ambiguous as to whether it was intended as a filename or a variable name.
Hence, I'd suggest looking very carefully at your calling sequence to ensure that it really is a correctly-formed filename w/ extension in every case and there's not some "sneak path" by which that isn't so.
Failing that, again, contact TMW official tech support at mathworks.com
Jan
Jan le 22 Juil 2013
The OP asked:
...after a call in the script to the print function, similar to this format:
print(CURRENT FIGURE HANDLE, '-dpdf', FILENAME)
It is impossible to find an error, when only some similar code is posted. Therefore, Megan, I suggest that you open a new question and add details.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by