MATLAB: Minimizing a function with one variable

minimizationoptimization

Hello expert,
I have to minimize the following function :
but i have just this constraint :
p, w, c are constants
thank you in advance for answering me

Best Answer

Is this what you're looking for?
p = pi;
w = 9*pi/56;
c = 5;
rmin = -40;
rmax = 40;
% inline function
fun = @(x)(0.5*p*x + 0.5*w*(x-c)^2);
options = optimset('PlotFcns',@optimplotfval,'TolX',1e-20,'MaxIter',50000);
% minimization
[r,fval,exitflag,output] = fminbnd(fun,rmin,rmax,options);
disp(['Value of r = ' num2str(r)]);
Related Question