MATLAB: How to find a minimum of this function of two variables

MATLABnumerical integration

I try to find a minimum (numerical value of variable 't') of function f(t) presented below.
Here's my attempt to code this problem (with Matlab error):
y = fminsearch(integral((abs(1/(-6*w^2/15 + 1 + 1i*(w-w^3/15)) - (heaviside(w)-heaviside(w-2*pi))/exp(1i*w*t)))^2,-Inf,Inf)/(2*pi),0)
??? Undefined function or variable 'w'.
How should I rearrange my code, in order to implement such a function and to obtain a right result?

Best Answer

f = @(t) integral( @(w) (abs(1./(-6*w.^2/15 + 1 + 1i*(w-w.^3/15)) - (heaviside(w)-heaviside(w-2*pi)) ./ exp(1i*w*t))).^2, -Inf, Inf) / (2*pi);
[best_t, fval] = fminsearch(f,0)
Related Question