Error: Cannot create output file
13 次查看(过去 30 天)
显示 更早的评论
In a matlab script printing multiple figures, I am trying to save as each figure as a .png image. I am doing so by using the print function. When testing the print function, I get the following:
>> print('newfile','-dpng')
Error using name (line 102)
Cannot create output file '.\newfile.png'.
Error in print (line 200) pj = name( pj );
Could anyone tell me how to fix this?
Thanks a lot.
0 个评论
采纳的回答
Jan
2018-1-23
The error message means, that the file "newfile.png" cannot be created in the current folder. Either this file is existing already, but write-protected or in use. Or you do not have write permissions in the current folder.
Prefer to define file names including the complete path, because you cannot control if a timer or GUI callback uses cd to change the current folder. Relying on the current folder to be, where it is expected, is not reliable.
3 个评论
Walter Roberson
2018-1-23
Yes you can use num2str and concatenation, but it is usually better to use sprintf and fullfile()
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!