Using 'assignin' to assign value to variable 'max'
古いコメントを表示
I'm using the 'assignin' function to assign a value to the variable 'max' using the code below:
function get_data
assign_value;
display(max)
end
function assign_value
assignin('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?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Fortran with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!