From: Adrian gavrila on
Hello,

I have an issue,
I have an fminsearch function but I need to input more that one value,
that is done, but as I run the function X0 goes out of bound:


x0=13.0e-3:0.1e-3:13.5e-3
options =optimset('Display','iter','MaxIter',100,'MaxFunEvals',40,'OutputFcn',@outfun)
[y,fval,exitflag,output]=fminsearch(@(y) PMSM_m_mod_optimiz(y),x0,options);

In y now it is only one variable now: y(1) from PMSM_m_mod_optimiz, I can put as many as 7 variables (this is done).

What I need to do is put for each variable an interval, like for :y(1)=[13.0...13.5]
so Fminsearch does not have to go over that.
I have tried x0=13.0e-3:0.1e-3:13.5e-3 but not working still going out of bound.

After this I need to implement the other 6 left variables and so I need to make a matrix with several lines, each line storing a variable.Correct me if my I judgment is wrong.

Please help me with this issue.
Thank you.
From: Steven Lord on

"Adrian gavrila" <adig_coool(a)yahoo.com> wrote in message
news:hq4n02$8c6$1(a)fred.mathworks.com...
> Hello,
>
> I have an issue,
> I have an fminsearch function but I need to input more that one value,
> that is done, but as I run the function X0 goes out of bound:
>
>
> x0=13.0e-3:0.1e-3:13.5e-3
> options
> =optimset('Display','iter','MaxIter',100,'MaxFunEvals',40,'OutputFcn',@outfun)
> [y,fval,exitflag,output]=fminsearch(@(y)
> PMSM_m_mod_optimiz(y),x0,options);
>
> In y now it is only one variable now: y(1) from PMSM_m_mod_optimiz, I can
> put as many as 7 variables (this is done).
>
> What I need to do is put for each variable an interval, like for
> :y(1)=[13.0...13.5] so Fminsearch does not have to go over that.
> I have tried x0=13.0e-3:0.1e-3:13.5e-3 but not working still going out of
> bound.
>
> After this I need to implement the other 6 left variables and so I need to
> make a matrix with several lines, each line storing a variable.Correct me
> if my I judgment is wrong.
>
> Please help me with this issue.

If you're looking to perform a CONSTRAINED search (bounds are a type of
constraint) then you can't use FMINSEARCH.

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fminsearch.html

"Find minimum of ***_unconstrained_*** multivariable function using
derivative-free method" [Emphasis mine.]

Since your function is not a function of one variable but as many as seven,
FMINBND won't work. Look at FMINCON in Optimization Toolbox.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: John D'Errico on
"Adrian gavrila" <adig_coool(a)yahoo.com> wrote in message <hq4n02$8c6$1(a)fred.mathworks.com>...
> Hello,
>
> I have an issue,
> I have an fminsearch function but I need to input more that one value,
> that is done, but as I run the function X0 goes out of bound:
>
>
> x0=13.0e-3:0.1e-3:13.5e-3
> options =optimset('Display','iter','MaxIter',100,'MaxFunEvals',40,'OutputFcn',@outfun)
> [y,fval,exitflag,output]=fminsearch(@(y) PMSM_m_mod_optimiz(y),x0,options);
>
> In y now it is only one variable now: y(1) from PMSM_m_mod_optimiz, I can put as many as 7 variables (this is done).
>
> What I need to do is put for each variable an interval, like for :y(1)=[13.0...13.5]
> so Fminsearch does not have to go over that.
> I have tried x0=13.0e-3:0.1e-3:13.5e-3 but not working still going out of bound.
>
> After this I need to implement the other 6 left variables and so I need to make a matrix with several lines, each line storing a variable.Correct me if my I judgment is wrong.
>
> Please help me with this issue.
> Thank you.

You cannot use fminsearch as Steve says, but you CAN
use fminsearchbnd, as found on the File Exchange.

http://www.mathworks.com/matlabcentral/fileexchange/8277

This tool allows upper and lower bound constraints on
the unknowns.

HTH,
John