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/')
>> 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).