Undefined function in MATLAB

2019-01-20 14:56发布

问题:

I using the function dtw in the latest MATLAB release, and would like to tweak a few parts of it. To get started, I typed:

edit dtw

I saved the resulting code to file called dtw_Copy.m, and changed the name of the function to dtw_Copy as well. Going through the code line by line with a set of input parameters x and y, around line 90:

[metric, varargin] = getmutexclopt({'absolute','euclidean','squared','symmkl'},'euclidean',varargin);

I receive an error message:

Undefined function 'getmutexclopt' for input arguments of type 'cell'.

I also get this error message if I do not go through the code line by line, and simply type dtw_Current(x,y), after again testing a set of input parameters x and y.

Upon running:

help 'getmutexclopt'

it is indicated that getmutexclopt is not found. I tried also:

edit 'getmutexclopt'

But am told that currentDirectory/getmutexcloptm.m does not exist.

I tried:

which getmutexclopt

And am told that getmutexclopt is not found.

Searching online, I found a resource that seemed straight-forward in trouble-shooting this error. The resource recommends to ensure the toolbox is installed. I am unsure which toolbox supports the function getmutexclopt, and so I type the function name into the website. This results in a message that: "Your search - getmutexclopt - did not match any documents."

The resource also recommends verifying the path used to access the function. I followed the instructions to do so, and when I typed:

which -all getmutexclopt

I receive:

currentDirectory\matlab\toolbox\signal\signal\private\getmutexclopt.m  % Private to signal

This seems to indicate that the function is in the signal toolbox, which is private? Is there a possibility to still run dtw_Current(x,y) and/or to run its contents line by line?

回答1:

Yes, this issue is because the function getmutexclopt is a private function. You'll need to make a copy of that function if you hope to safely call it from your copy of dtw. It appears to be a basic function (type edit private/getmutexclopt.m in your Command Window) so you may be able to add it as a sub-function to your dtw_Copy/dtw_Current.

See also this question – adding private functions to the search path is not allowed.