MATLAB: Inner product (the result is out of the control)

inner product

Thank you so much for your attention for my question, the following is my code:
% function responsenum = numresponse(num)
switch num
case 1
responsenum=@(x,y)x+y;
case 2
responsenum=@(x,y)x+y;
function y = innerprod(fun1,fun2)
y = @(x,y)fun1(x,y).*fun2(x,y);
x = -1:0.1:1;y = -1:0.1:1;
metag = @(x,y)innerprod(numresponse(1),numresponse(2))
z = metag(x,y);
In my opinion, variable z should be a matrix, but it is a function, could you give me some help about this problem, i will be very appreciated for your kindness!

Best Answer

You are getting confused because you are putting a function (returned by innerprod) inside another function (which you call metag), but you don't need to nest them at all! What you need is to simply call this:
metag = innerprod(numresponse(1),numresponse(2));
z = metag(x,y);
because innerprod already returns a function, there is no point in you sticking it inside another function.