I'm using the 'assignin' function to assign a value to the variable 'max' using the code below:
function get_dataassign_value;display(max)endfunction assign_valueassignin('caller','max',5);end
If I run 'get_data' from the command line, I get an error that I'm not passing enough input arguments to 'max,' since 'max' is a built-in function to MATLAB.
Interestingly, I can add the output 'max' to the function 'get_data' by writing
function max=get_data
and the function will run and display the value '5'.
My questions are:
1) Is this how 'assignin' is supposed to behave, i.e. does it not assign a value to a variable if the variable name is an instrinsic function in MATLAB?
2) Why is 'assignin' not able to assign value to 'max,' but I can execute 'max=5' in other contexts and MATLAB won't complain?
Best Answer