hi,
Everytime i try to save a variable into matlab file, it appears like this
>> save('28-10-2015 list of 87 gap reaction.mat','gapEquation')
Error using save
Unable to write file 28-10-2015 list of 87 gap reaction.mat: permission denied.
does any of you know how to fix it?
im using matlab version R2014b
thanks,

 채택된 답변

Guillaume
Guillaume 2015년 10월 28일

0 개 추천

Most likely, the issue is not with matlab. There can be may reasons why a permission denied error occurs:
  • the file exists and is open by an application (matlab or something else)
  • you do not write access to the current directory
  • your antivirus is messing things up
  • this is on a network share and the file server has a rule blocking files with a pattern that match yours
  • etc.
Can you save the file with a different filename? Can you save it in a different location? Can you save any mat file?

댓글 수: 4

Nhung Pham
Nhung Pham 2015년 10월 28일
편집: Nhung Pham 2015년 10월 28일
Hi Guillaume,
thanks for your answer.
i realize that i cannot save the file to the matlab directory in program file. but when i change the location, it works. So do you think what is wrong here, may be because of my antivirus?? what should i do now, i cannot change the location back and forth whenever i want to save a variable. it is such an inconvenience :-(
Nothing is really wrong. The operating system decided or was told not to let you write to that folder so it doesn't let you/MATLAB write to that folder. MATLAB tells you that it was denied permission to write to the folder.
The SAVE function can accept not just file names, but also paths to files. I'm assuming (from your reference to "program file") that you're on Windows: if so try this.
x = 1:10;
save('c:\temp\mymatfile.mat', 'x')
No matter what directory you're in, this will save the MAT-file named mymatfile.mat in c:\temp (assuming that folder exists.)
Guillaume
Guillaume 2015년 10월 28일
Indeed that's been standard windows behaviour since Windows 7 for the OS to prevent you from writing files in the 'Program Files' directory. There are ways to bypass this but in any case, you really shouldn't be saving your mat files there. By default matlab home directory is in 'My Documents'. Why don't you save there.
Nhung Pham
Nhung Pham 2015년 10월 28일
It is true that i'm using windows. Stupid me to save all the files in the program file without notice it.
Thanks a lot Steven Lord and Guillaume. i know what to do now :-)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

질문:

2015년 10월 28일

댓글:

2015년 10월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by