Reputation: 1044
I wrote this m-file
function adhamm = adhamm(a,b)
adhamm = a+b
end
and when I try to run it via MATLAB's command line by writing
a = 2;
b = 3;
adhamm(a,b);
I get this error
Undefined function 'adhamm' for input arguments of type 'double'.
Why is this?
Upvotes: 0
Views: 927
Reputation: 16045
You've probably saved a variable with name adhamm
. Type clear adhamm
and try again.
Upvotes: 0
Reputation:
These functions were not placed in the search path for the new version. MATLAB simply does not know where to find them. However, do NOT place them in a MATLAB toolbox directory. That is not the place to put your own functions. Put them in a separate directory that you will tell MATLAB how to find using the path tools. (If you cd to that directory, MATLAB will automatically look there, but that is not a good solution.)
You need to learn about the search path in matlab, and the tools matlab has to maintain search paths. Thus, addpath, savepath, rmpath, pathtool.
Upvotes: 1
Reputation: 98
you saved your function with the name adhamm.m, right? Then try to execute the function within the folder of adhamm.m.
Upvotes: 0