Saveas error-Cannot create output file
조회 수: 29 (최근 30일)
이전 댓글 표시
Hello,
i write this very simple code in MATLAB R2020b:
clear
clc
close all
x=[1 2 3 4 5];
y=x;
plot(x,y)
saveas(gcf,'Image.jpg');
But i obtain this error:
Error using matlab.graphics.internal.name (line 101)
Cannot create output file '.\Image.jpg'.
Error in print (line 71)
pj = matlab.graphics.internal.name( pj );
Error in saveas (line 181)
print( h, name, ['-d' dev{i}] )
Error in test (line 7)
saveas(gcf,'Image.jpg');
How to solve this problem? I want to save the figure in jpg format.
댓글 수: 1
Abubakar Abba
2021년 9월 11일
It means you are trying to save a figure in an un identified path. Try to go to the actual directory and Run
the code again, it will work.
채택된 답변
Bharathi Sunkara
2020년 11월 5일
Hi Edoardo,
As per my understanding, error message means, that the file “Image.jpg” cannot be created in the current folder.
This means that either this file is existing already but write-protected or in use. or you do not have write permission in the current folder.
As a workaround I would recommend you to define file names including the complete path.
Hope this Helps!
댓글 수: 2
lopamudra singh
2023년 10월 4일
I am running in online MATLAB and still facing the same error, where I do not have any additional folder or directory.
추가 답변 (1개)
Safa Sharif
2021년 7월 20일
hi, im still getting this issue and have permission. can anyone advise why?
댓글 수: 1
Abubakar Abba
2021년 9월 11일
It means you are trying to save a figure in an un identified path. Try to go to the actual directory and Run
the code again, it will work.
참고 항목
카테고리
Help Center 및 File Exchange에서 Printing and Saving에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!