I am testing a part of a function for my work in MATLAB. I have defined a function and subfunction as follows(just for testing):
function funct clear all; clc; I
I don't have the image processing toolbox, so I can't check this myself, but it looks like nlfilter expects a function of just one argument. Try changing the call to nlfilter like this:
nlfilter
A = nlfilter(I, [7 7], @(x) dirvar(x,ld));