exportgraphics does not save at specific location
이전 댓글 표시
I have a figure that I want save with exportgraphics(), but I get an error about the path.
>> str_save = '~/Documents/MATLAB/A/B/C/test_file_name.pdf';
>> isfolder('~/Documents/MATLAB/A/B/C/')
ans =
logical
1
>> exportgraphics(fig, str_save)
Error using exportgraphics
Problem while processing in an OutputHelper. ~/Documents/MATLAB/A/B/C/test_file_name.pdf (No such file or directory)
com.mathworks.hg.util.OutputHelperProcessingException: Problem while processing in an OutputHelper. ~/Documents/MATLAB/A/B/C/test_file_name.pdf (No such file or directory)
at com.mathworks.hg.util.HGVectorOutputHelper.open(HGVectorOutputHelper.java:76)
Caused by: com.mathworks.hg.print.OutputProcessingException: ~/Documents/MATLAB/A/B/C/test_file_name.pdf (No such file or directory)
at com.mathworks.hg.print.BaseVectorStrategy.open(BaseVectorStrategy.java:30)
at com.mathworks.hg.util.HGVectorOutputHelper.open(HGVectorOutputHelper.java:66)
If I save it to the current working directory
str_save = './test_file_name.pdf';
it works. When I save it with print() instead of exportgraphics() it also works.
Adding the output folders to the current path (via GUI or code) does not change the error.
Could this have to do with write access? But checking the rights with fileattrib() says I have write access (which should be the case since the folder is created in my script with 774 rights).
채택된 답변
추가 답변 (1개)
The folder is existing but Matlab cannot create a file in it. Then Matlab does not have write permissions in this folder.
fileattrib('~/Documents/MATLAB/A/B/C/')
Allow the current user to create files in this folder.
댓글 수: 4
Felix Müller
2022년 6월 29일
Is this successful:
str_save = '~/Documents/MATLAB/A/B/C/test_file_name.pdf';
[fid, msg] = fopen(str_save, 'w');
assert(fid > 0, '%s', msg)
Is this the real path name or is "A/B/C" an abbreviation of a name containing Unicode characters?
Felix Müller
2022년 6월 29일
Felix Müller
2022년 7월 1일
카테고리
도움말 센터 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!