I have a MATLAB function that uses the EVAL command to create a variable in the workspace. The variable being created has the same name as a MATLAB function. When I try to use the variable later, MATLAB instead tries to call the function with the same name. For example:
function testa = 1;b = 2;c = 3;names = {'a','b','c'};for idx = 1:length(names) eval(['sum.', names{idx}, '=', names{idx}, ';'])endexist('sum')sum
When I run this code, the EXIST function properly returns 1, indicating that "sum" is a variable. However, when I try to display the value of "sum" on the last line of the file, I receive the following error:
??? Error using ==> sum Not enough input arguments.
Best Answer