MATLAB: How to optmize this function:

fminconoptimization

I would like to do the optimization of a function that returns me a value(time). The idea is use different values of the inputs (i1,i2,i3,i4)and analyze all the times obtained. The optimal result will be the one that returns lowest time.
function [time]=function1(i1,i2,i3,i4)
How can I do this optimization with the fmincon (or another matlab function) to optimize this process, in order to avoid doing:
for i1=1 to 100 for i2=1 to 100 for i3=1 to 100 for i4=1 to 100 time=function1(i1,i2,i3,i4) […] end end end end
Thank you

Best Answer

Since you don't mention any constraints, FMINUNC might be more appropriate. You need an initial guess of the parameters
x0=[i1,i2,i3,i4];
and you would then do
x=fminunc(@(x) function1(x(1),x(2),x(3),x(4)), x0 );
Of course, fminunc has many different parameters and options you can set, which are discussed in the documentation.
Related Question