fun=@(t) integral2(k, 0, x, 0, y)-z;
Where are you using the input value, t ?
No, the t parameter will not be passed into k just because k happens to be a function whose dummy parameter name is the same as t.
Remember, this is integral2(), so the first parameter (k here) must evaluate to the handle of a function that accepts x and y values. For example,
fun = @(t) integral2(@(x,y)k(x,y,t), 0, x, 0, y) - z;
Your x is a vector, but you are trying to use that vector as the upper bound for integral2(). integral2() can only accept one scalar bound at a time.
If you want to fit at several x and y then you can break the overall x range into pieces, and the y range into pieces, and integrate over the rectangles, and cumsum() in two directions in order to get the grid.