Hi everyone. I encountered a strange problem about function and variable names. I tried this
clear allclose allalpha=1;save ('data1.mat')test1
Where test1 is the function
function test1 load data1.mat % which contains only variable alpha
alpha % to see the value of alpha
And the error appeared, as if I called function alpha instead of variable alpha. As I know, when we name a variable same as a builtin function, matlab treats that name as a variable name whenever it is called (and we should avoid that style of naming).
Also, in my case, I used 'whos' command to see if there was a variable named 'alpha' in the workspace after load function. And I did have that 'alpha' variable. Just why this problem happened? All the functions, .mat file are in the same folder. I've tried in Matlab 2016a,b and 2017b.
Best Answer