rename m.file / Simple

조회 수: 258 (최근 30일)
Max Müller
Max Müller 2014년 9월 18일
댓글: Adam 2014년 9월 18일
Hey guys, how can i rename a function, which was save in a m.file ? When i started working i gave them stupid name, like PloToCompareResults. Now I want to rename them, but matlabs responds with: this function will be know to matlab as "oldname".How cn change that ?
  댓글 수: 1
Adam
Adam 2014년 9월 18일
I assume you are just working with local files rather than in a repository such as Hg or SVN?
If so then just renaming everywhere the old name is used works fine, if you are using a repository and have committed the files you need to be more careful with the file renaming.
Also if you have files created by GUIDE you need to do a 'Save As' from within GUIDE to rename while retaining all callback linkages in the associated .m file. Then delete the old file.
Before doing any of this make sure your workspace is empty though and preferably close all relevant files to avoid any problems.

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

답변 (1개)

Guillaume
Guillaume 2014년 9월 18일
You need to rename:
  • the function declaration (i.e. function argout = oldname(argsin) to function argout = newname(argsin))
  • the function m file (i.e oldname.m to newname.m)
  • any call to the function
for it to all work. Matlab refactoring tools are very minimal so you'll have to do it manually (or write a fairly sophisticated script to do it).

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by