My colleagues tend to criticize my use of nested functions in MATLAB, likening that to the professional no-no of modifying global variables. To placate those peers, I'll recode those methods that use nested functions into a handle-based object-oriented methods. Now, they accept that the current properties are accessible to the object's methods.
However, I have a specific instance where the nested functions implementation outperforms the handle-based object-oriented programming style: k-D Trees.
Here is the benchmark code run from the command window.
pdat = randn(130001,3);
tic;a_tree = kDTree(pdat); disp(toc)
tic;i_tree = ikdtree(pdat);disp(toc)
I'm seeking insights into what is causing these performance differences.