fminbnd: setting constraint to function value to be positive

3 views (last 30 days)
Varying the variable 'jtot' I would like to find the inertia that gives me the specified rms-torque-value 'trmsduty'. Therefore I search for zero difference between trmsduty and the function specifying the rms value depending on 'jtot'. First I tried using fzero, this didn't work as there was a complex function value found. Now I try using fminbnd. I set up the following optimization routine :
function [jtotmax] = solve_torque()
[trmsduty,ji,omegadot,tres,k,jtrasm,jmot] = ex2_sin();
f =@(jtotmax) trmsduty^2 -(1/1200).*(trapz(power([jtotmax.*omegadot(1:401)+tres zeros(1,199) ji.*omegadot(601:1001) zeros(1,199)],2)));
[jtotmax,fval] = fminbnd(f,0,.001);
%jtotmax = fzero(f,0.001)
jmmax = jtotmax-jtrasm-jmot;
mmax = jmmax*k;
end
I find the problem, that the minimum of f is a negative value. I'm looking for a way to set the constraint that fval can only be positive (close to zero...).
  3 Comments
Karl
Karl on 15 Jun 2017
Thanks a lot! I had a mistake in my function, there was no feasible solution as I saw now. This is why fzero didn't work in the first place.
John D'Errico
John D'Errico on 15 Jun 2017
You cannot set a constraint on the function value using fminbnd.

Sign in to comment.

Answers (0)

Categories

Find more on Optimization in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!