How to use fminunc in Matlab on only some specified parameters of a function

So I want to use fminunc(fun, X0) in Matlab on my function fun. The problem is that fun is a function of three parameters:(X, y, X0), all of which are vectors. What I want to do is to find the minimum, given the parameters X, y. I.e. the vector X0 which minimises the function for some given values X, y. How would I go about doing this?

% function to be minized