MATLAB 6.5 (R13) sometimes attempts to call a function when I am trying to use a variable with the same name as that function. There is no mention of this in the documentation.
I have written a function that calls a script. The script creates and initializes several variables. These variables are then used in the function. However, one of the variables has the same name as a MATLAB function, and that function is called when I try to reference the variable. The rules of precedence say that the variable should be used instead of the function.
For example, running the attached function 'foofunc' (given with fooscript below) will give the following error because MATLAB attempts to use the MATLAB function "day" instead of my variable "day" when resolving the statement 'x = day':
ERROR: ??? Error using ==> dayPlease enter D.Error in ==> D:\Applications\MATLAB\R13\work\foofunc.mOn line 3 ==> x = day;
Here is the example function, foofunc.m:
function foofuncfooscript;x = day;
Here is the example script file, called fooscript.m:
day = 3;
Best Answer