Path: news.mathworks.com!newsfeed-00.mathworks.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: Scott Seidman <namdiesttocs@mindspring.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Find Minimum
Date: 12 Feb 2008 01:01:01 GMT
Organization: Your Company
Lines: 44
Message-ID: <Xns9A41CB9F7F21Dscottseidmanmindspri@130.133.1.4>
References: <ac460e51-a1a5-4e93-9031-220be5a23e5a@f10g2000hsf.googlegroups.com> <Xns9A419793662B6scottseidmanmindspri@130.133.1.4> <foqah7$fds$1@canopus.cc.umanitoba.ca> <Xns9A419D4C96F57scottseidmanmindspri@130.133.1.4> <foqcnc$i3l$1@canopus.cc.umanitoba.ca> <59c7a60a-4c16-401e-a6a2-4a1cb1901c3d@z17g2000hsg.googlegroups.com>
X-Trace: individual.net ZKO/DdkE6iW6TxuvrRw0agzgvqwQ5dmfVaxp5DAQKWOh1LtmA=
Cancel-Lock: sha1:jUQVpHfd8yOzbxn2UuFz6CWa7zY=
User-Agent: Xnews/5.04.25
Xref: news.mathworks.com comp.soft-sys.matlab:450699


shapper <mdmoura@gmail.com> wrote in news:59c7a60a-4c16-401e-a6a2-
4a1cb1901c3d@z17g2000hsg.googlegroups.com:

> Evaluate my function at all 4,000,000? Now I am scared ... :-)
> 

I looped through 4,000,000 multiplies to test, and it took about 5 
seconds.

Walter is offering some elegant vectorial solutions that would be a good 
deal faster, but brute force is to go with loops nested three deep. 
Evaluate the function, and if its lower than any previous value, replace 
it

 
Amin=0
Bmin=0
Cmin=0
Fmin = 10^20  %Some big number

for A=0:2000
for B=0:10:200
for C=[0:0.01:1]

F= somefunc(A,B,C)

if F<Fmin
F=fmin
Amin=A; Bmin=B; Cmin=C;
end %if

end  %Cloop
end  %Bloop
end  %Aloop

Fmin
Amin
Bmin
Cmin


-- 
Scott
Reverse name to reply