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

2 ビュー (過去 30 日間)
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 件のコメント
Ade Aulya
Ade Aulya 2018 年 5 月 30 日
編集済み: Walter Roberson 2018 年 5 月 30 日
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 2018 年 5 月 30 日
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.

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

回答 (1 件)

Yu Jiang
Yu Jiang 2014 年 8 月 27 日
編集済み: Yu Jiang 2014 年 8 月 27 日
There should be no spaces in the path or the file name.
  1 件のコメント
Walter Roberson
Walter Roberson 2018 年 5 月 30 日
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.

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

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by