updating function list in a script.

조회 수: 4 (최근 30일)
David H
David H 2014년 8월 26일
편집: David H 2014년 8월 27일
As part of some code I am writing I am printing out symbolic variables into a .m file (so that they can be called with d.p. arguments without using the incredibly sluggish subs). This works well except that when I create a new function matlab does not automatically note that the function has changed and will either not notice the function is present, complain about the arguments of the function, or use an old overwritten version.
Is there any command to update the list of possible functions (within the same working directory) or any other way to solve this problem?
  댓글 수: 2
Star Strider
Star Strider 2014년 8월 26일
I don’t know how you’re creating your funcitons, but starting with R2012a, you can create symbolic functions. You can also create anonymous functions or function m-files from symbolic expressions with matlabFunction. That might make things easier in your application.
David H
David H 2014년 8월 27일
편집: David H 2014년 8월 27일
Yes I was unaware of this, it seems to be much easier to work with than the function I wrote which just copies it as characters, and so doesn't work for matrix inputs and things like that.

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

채택된 답변

dpb
dpb 2014년 8월 26일
>> help rehash
rehash Refresh function and file system caches.
rehash with no inputs performs the same refresh operations that are done
each time the MATLAB prompt is displayed--namely, for any non-toolbox
directories on the path, the list of known files is updated, the list of
known classes is revised, and the timestamps of loaded functions are
checked against the files on disk. The only time one should need to use
this form is when writing out files programmatically and expecting
MATLAB to find them before reaching the next MATLAB prompt.
  댓글 수: 2
Sean de Wolski
Sean de Wolski 2014년 8월 26일
This is also mentioned in the "Tips" section of the doc for matlabFunction.
An enhancement request proudly submitted by me :)
David H
David H 2014년 8월 27일
I find that rehash does not completely work for me, but matlabFunction seems to solve my problems anyway with the options available. So that will be fine.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by