Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % I could use sum(vectorized_expr) but this form is more obvious
- f = @(x) cos(10*x(1))+(x(1)-0.01)^2 + cos(20*x(2)) + (x(2)-0.02)^2 + ...
- cos(30*x(3)) + (x(3)-0.03)^2 + cos(40*x(4)) + (x(4)-0.04)^2 + ...
- cos(50*x(5)) + (x(5)-0.05)^2 + cos(60*x(6)) + (x(6)-0.06)^2 + ...
- cos(70*x(7)) + (x(7)-0.07)^2
- opts = intoptimset();
- opts(1) = 1e-2; % ftol
- x0 = [infsup(0,1), infsup(0,1), infsup(0,1),infsup(0,1), infsup(0,1), infsup(0,1), infsup(0,1)];
- tic
- x = intminunc(f, x0,opts)
- toc
- Output:
- ...
- 610 5701 4600 570 610 -6.338e+00 0 321 0.359
- ...
- >> toc
- Elapsed time is 339.014638 seconds.
Advertisement
Add Comment
Please, Sign In to add comment