getting error "error writing file name.m C:\program files\matlab\folder name\file name.m(access is denied) "

2 Ansichten (letzte 30 Tage)
getting error stated in MATLAB editor window i.e. error writing file name.m C:\program files\matlab\folder name\file name.m(access is denied)
  4 Kommentare
Ade Aulya
Ade Aulya am 30 Mai 2018
Bearbeitet: Walter Roberson am 30 Mai 2018
hi, @hamidreza eslami
i really beg your pardon for this stupid question. i have tried as u said but i still got the same error.
like from here :
filePattern = fullfile('C:\Users\DataBaseBC\DATABC1\Train 50%', '*.tif');
tiffFiles = dir(filePattern);
to :
filePattern = fullfile('C:\Program Files\MATLAB\R2017a\DATABC1\Train 50%', '*.tif');
tiffFiles = dir(filePattern);
was it right ?
what should i do ?
Walter Roberson
Walter Roberson am 30 Mai 2018
Ade Aulya,
The error message involved in this Question has to do with permission denied when attempting to write to a file. The code you show is only trying to see which files are in a directory, and would not itself try to write to any files. You might have another bit of code later that is trying to write to a file.
If you are trying to write to files in C:\Program Files\MATLAB\R2017a\DATABC1\Train 50% then that is not a good place to store the files. MS Windows does not permit users to write inside the Program Files directory.
On the other hand, the code you posted does not attempt to change directory and does not in itself pull out the directory name C:\Program Files\MATLAB\R2017a\DATABC1\Train 50% to write files to. It is possible that you are trying to write files into whatever your current directory is, and that might be a location that you do not have write access to.
We would need to know what your current directory is, and we would need to see more of your code.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Yu Jiang
Yu Jiang am 27 Aug. 2014
Bearbeitet: Yu Jiang am 27 Aug. 2014
There should be no spaces in the path or the file name.
  1 Kommentar
Walter Roberson
Walter Roberson am 30 Mai 2018
This is not really correct. There is no problem in MATLAB in writing files inside directories that happen to have spaces in the name, and no problem writing files that have spaces in the name.
Historically, Simulink was not properly configured in a number of locations and so historically Simulink did have problems with directories or files that had spaces in the name.
But the problem in the original posting had to do with users attempting to write inside the Program Files directory, which Microsoft does not permit users to write into.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by