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
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
Bharathi Sunkara 2020 年 11 月 5 日

0 投票

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 件のコメント

EDOARDO BUOLI
EDOARDO BUOLI 2020 年 11 月 9 日
Thanks. It was a problem with the write permission. I solved the problem by changing the write permission in my antivirus.
lopamudra singh
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
Safa Sharif 2021 年 7 月 20 日

0 投票

hi, im still getting this issue and have permission. can anyone advise why?

1 件のコメント

Abubakar Abba
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.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で MATLAB についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by