How to use fminunc in Matlab on only some specified parameters of a function
What we have here is a function fun(X, y, X0) and fminunc(fun,X0). You know X, and y, lets call them X* and y*, so we could replace fun(...) by fun*(X0)

% function to be minized
fun = @(X, y, X0) (dot(X,y) + X0)^2   
X_star = [1,2,3]
y_star = [4,5,6]
$ same function but with X and y filled in
fun_star = @(X0) fun(X_star, y_star, X0) 
X0_star = 0
fminunc(fun_star, X0)