フィルターのクリア

Resolving "Permission Denied" when creating a file.

147 ビュー (過去 30 日間)
Claire
Claire 2023 年 10 月 16 日
コメント済み: Claire 2023 年 11 月 1 日
I am currently trying to include an animation in my code, but when I run it, I get an error message saying, "Cannot create file PS4_animation. Permission Denied." How can I resolve this?
  3 件のコメント
Torsten
Torsten 2023 年 10 月 16 日
To test for write access, try to save a test file there (independent of MATLAB).
Claire
Claire 2023 年 11 月 1 日
Thank you! I ended up just separating the code that was causing the problem by running it on a new page, which seemed to resolve the problem.

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

採用された回答

Infinite_king
Infinite_king 2023 年 10 月 30 日
編集済み: Infinite_king 2023 年 10 月 30 日
Hi claire,
I understand that you are encountering ‘permission denied’ error while creating a file.
It is possible that you might not have read/write access to the file or the folder. To check if you have write access, please refer to the following code snippet,
% Enter the path of the folder/file
nameORpath = 'file_name or folder_path';
% check if the folder exists
if exist(nameORpath) == 7
disp('folder exists')
else
disp('folder does not exists')
end
% check if the file exists
if exist(nameORpath) == 2
disp('file exists')
else
disp('file does not exists')
end
% check if you have write access
[status, attributes] = fileattrib(nameORpath);
if status && attributes.UserWrite
disp('You have write access');
else
disp("You don't have write access");
end
If you don’t have write access, you can obtain the access as follows,
  1. Run MATLAB as Administrator if you have windows system.
  2. You can obtain the write access through the functions as follows,
fileattrib(nameORpath,'+w')
If you are unable to access the file even after following the above steps, then it is most likely that your user account doesn’t have access to that file/folder.
For more information, kindly refer to the following MATLAB resources about ‘exist’ and ‘fileattrib’ function,
  1. https://www.mathworks.com/help/matlab/ref/exist.html
  2. https://www.mathworks.com/help/matlab/ref/fileattrib.html#bvczjwl
Hope this is helpful.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by