Torsten
Posts:
1,546
Registered:
11/8/10


Re: Maximize function with fminsearch
Posted:
May 2, 2012 5:44 AM


On 2 Mai, 09:30, "Francesco Perrone" <francesco86perr...@yahoo.it> wrote: > Good Morning everybody, > > I have a pretty straightforward question: within my daily work, I have got to maximize a particular function making use of fminsearch; the code is this > > clc > clear all > close all > > f = @(x,c,k) (x(2)/c)^3*(((exp((x(1)/c)^k)exp((x(2)/c)^k))/((x(2)/c)^k(x(1)/c)^k))exp((x(3)/c)^k))^2; > c = 10.1; > k = 2.3; > X = fminsearch(@(x) f(x,c,k),[4,10,20]); > > It works fine, as I expect, but not the issue is coming up: I need to bound x within certain limits, as: > 4 < x(1) < 5 > 10 < x(2) < 15 > 20 < x(3) < 30 > > To achieve the proper results, I should use the optimization toolbox, that I unfortunately cannot hand. > > Is there any way to get the same analysis by making use of only fminsearch? > > I thank you in advance. > > Best regards, > Francesco
Sure. In your objective function, replace x(1) by 4.5+0.5*sin(x(1)), x(2) by 12.5+2.5*sin(x(2)) and x(3) by 25+5*sin(x(3)).
Best wishes Torsten.

