Why do I get an error when I am trying to write to a file using IMWRITE in MATLAB 7.8 (R2009a)?
조회 수: 10 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2009년 10월 1일
편집: MathWorks Support Team
2024년 8월 8일
I am trying to write to a file with IMWRITE function. I am trying to create a path to a file in a folder that does not exist:
Z = peaks; surf(Z)
axis tight
set(gca,'nextplot','replacechildren');
surf(sin(2*pi/20)*Z,Z);
F = getframe;
imwrite(F.cdata,'newFolder/testfile.jpeg','jpg')
I get the following error:
ERROR: ??? Error using ==> imwrite at 409
Can't open file "newFolder/testfile.jpeg" for writing.
You may not have write permission.
채택된 답변
MathWorks Support Team
2024년 8월 8일
편집: MathWorks Support Team
2024년 8월 8일
You need to make sure that the path to file that you specify for IMWRITE exists. You can use MKDIR command to create the directory. Consider the following example:
mkdir('newFolder')
imwrite(F.cdata,'newFolder/testfile.jpeg','jpg')
For more information on the MKDIR function, please refer to the documentation by executing the following in the MATLAB command prompt:
doc mkdir
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!