Function handlers in Octave are defined as an example below.
f = @sin;
From now on, the calling function f(x)has the same effect as the call sin(x). So far, so good. My problem starts with the function below from one of my programming assignments.
function sim = gaussianKernel(x1, x2, sigma)
The line above represents the function header gaussianKernel. Three variables are used as input. However, the call below turns me on because it only passes two variables, and then three, referring to gaussianKernel.
model = svmTrain(X, y, C, @(x1, x2) gaussianKernel(x1, x2, sigma));
Isn't that easy model = svmTrain(X, y, C, @gaussianKernel(x1, x2, sigma));? What is the difference?
source
share