MATLAB: What does this command: “@(x) Function” means in matlab

@anonymous function

function mse_calc = mse_test(x, net, inputs, targets)
net = setwb(net, x');
y = net(inputs);
mse_calc = sum((y-targets).^2)/length(y);
end
inputs = (1:10);
targets = cos(inputs.^2);
n = 2;
net = feedforwardnet(n);
net = configure(net, inputs, targets);
h = @(x) mse_test(x, net, inputs, targets);
ga_opts = gaoptimset('TolFun', 1e-8,'display','iter');
[x_ga_opt, err_ga] = ga(h, 3*n+1, ga_opts);

Best Answer

That's a function handle. See this link:
The function handle can point to an existing function (e.g., an m-file function), or it can point to an anonymous function (i.e., one created on the fly at the handle creation). E.g.
>> a = 5 % a constant
a =
5
>> b = 3 % another constant
b =
3
>> h = @(x) a*x+b % an anonymous function handle for the linear expression a*x+b
h =
@(x)a*x+b
>> h(4) % evaluate the function handle h for an input of 4
ans =
23
>> h(7) % evaluate the function handle h for an input of 7
ans =
38