How to edit MATLAB file kmeans.m?

조회 수: 1 (최근 30일)
hello_world
hello_world 2016년 8월 8일
편집: Stephen23 2016년 8월 9일
Hello Friends,
I want to edit kmeans.m but it does not allow me to make any changes. I tried 'fileattrib' to make it writable file by
fileattrib('kmeans.m', '+w');
but even this does not work. I also tried to give the full path as follows:
fileattrib('/usr/local/MATLAB/R2014a/toolbox/stats/stats/kmeans.m','+w')
Error using fileattrib
Operation not permitted
I will appreciate any advise.
  댓글 수: 1
Stephen23
Stephen23 2016년 8월 9일
편집: Stephen23 2016년 8월 9일
Do NOT edit or change any MATLAB toolbox files.
This has two very significant risks:
  1. introducing bugs, which then cannot be reverted because you have changed the original file and you no longer have an original version.
  2. changing function behavior and outputs: other functions may depend on the one that you edit. Will they still work correctly ? How do you know ?
If you want to write some code based on a MATLAB toolbox file, always copy it to your user directory and work with that copy only. Never replace the original files.

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

답변 (1개)

the cyclist
the cyclist 2016년 8월 8일
I would strongly advise against directly editing a read-only MATLAB file.
Instead copy it to your own directory, and edit your own file ...
copyfile /Applications/MATLAB_R2016b.app/toolbox/stats/stats/kmeans.m ./my_kmeans.m
It will still be read-only, but after make changes and try to save, you will be given an option to overwrite.
  댓글 수: 2
hello_world
hello_world 2016년 8월 9일
Thanks for this reply. I already knew this option but this does not help me because I want to call Davies-Bouldin Criterion using kmeans clustering. In order to do so, I must change other MATLAB files and save them in a different directory. I tried to change some of them, but there are some which I could not change because it gives error. I do not know why.
Adam
Adam 2016년 8월 9일
You would have to copy them in that case. Matlab toolbox files are not meant to be messed around with and edited.

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

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by