fminbnd: setting constraint to function value to be positive

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

Have you looked at the result of your function over the independent variable you're trying to solve for? Is there a feasible solution at all?
As written, nobody here can run it to try anything as we don't have ex2_sin
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.
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

Asked:

on 15 Jun 2017

Commented:

on 15 Jun 2017

Community Treasure Hunt

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

Start Hunting!