Hi!
I have a function of T as,
CV_inf = @(T) T.*(4/(n+1)) - integral(@(t) psitildasq(t),(-T),(T),'Arrayvalued',true);
where
psitildasq = @(t) (1/n^2)*(sum(cos(x*t))).^2 + (1/n^2)*(sum(sin(x*t))).^2;
x is a (1*n) vector of inputs.
I want to find the global minimum as well as the first(smallest) local minimum of this function.
To find the global minimum I use
[Tinf,Tinf_val,Tinf_exitflag,output] = fminsearch(CV_inf,0);
and to find the local minimum I follow this method,
[Tloc1,Tloc1_val,Tloc1_exitflag] = fminbnd(CV_inf,0,Tinf); g = Tinf - Tloc1; if g <= 0.0001 Tloc = Tinf; Tloc_val = Tloc1_val; Tloc_exitflag = Tloc1_exitflag; else while g > 0.0001 [Tloc,Tloc_val,Tloc_exitflag] = fminbnd(CV_inf,0,Tloc1); g = Tloc1 - Tloc; Tloc1 = Tloc; end end
But when I have a large dataset like n=10000, the code seems to run forever. Could there be a possibility of speeding up the process?
Thanks.
Best Answer