plz explain the code
显示 更早的评论
采纳的回答
更多回答(1 个)
Walter Roberson
2018-9-28
1 个投票
The second line is an example of using an anonymous function to parameterize code. At the time the anonymous function is created (not when it is executed!) the current value of the variable contour_thres will be examined and will be stored internally with the anonymous function. Any change to the variable contour_thresh after that will not affect the anonymous function.
So the anonymous function created is one that, given any single input variable, will try to use the < operator appropriate to the variable's data type in order to do a comparison-like operation between the input and the value 0.005 . The formal name of the < operator is lt(), so at the time of execution of the function handle, MATLAB will examine the datatype of the input that it is passed, and will find the gt() function for that datatype, and will execute that gt() passing in x and 0.005 . Typically the input for such a handle would be double precision data type, so typically it would be /Applications/MATLAB_R2018a.app/toolbox/matlab/ops/@double/lt (or equivalent in your installation) that was executed when the anonymous function was invoked.
The meaning of the < operator will depend upon the data type of the input, x, but mostly it is used to signify comparison of values to produce an output of data type logical that is the same size as the input.
类别
在 帮助中心 和 File Exchange 中查找有关 Image Arithmetic 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!