Search code examples
matlabworkspace

Matlab: How to override intrinsic function with variable in workspace


I would like to know how to override an intrinsic function with a variable defined in the workspace in Matlab R2015a when running an m file.

I mean if I define:

function test
fun1
clear input
load test
plot(input)
return

function fun1
input=1:10;
save('test.mat','input')
return

and I run test, then I get:

Error using input
Not enough input arguments.

Error in test (line 8)
plot(input) 

Matlab is taking input as its in-built function.

Do you know how to solve this (without changing the variable name)?

Thanks.


Solution

  • The solution is given in the comments by @Dev-iL

    Better not to spawn variables into existence variables in the workspace.

    So this would make the simple example above to work:

    A=load('test.mat');
    input=A.input