Optimization Functions in MATLAB
Optimization functions in MATLAB are categorized into Optimizers, Equation Solvers, and Output
Controllers.
1) Optimizers
a) fminbnd
Purpose: Finds the local minimum of a single-variable function within a specified interval.
Syntax:
x = fminbnd(fun, x1, x2)
Description: Returns the value of x that minimizes the scalar-valued function fun in the
interval x1 < x < x2.
Arguments:
o fun: Function handle for the scalar-valued function to minimize.
o x1, x2: Bounds of the interval.
b) fminsearch
Purpose: Finds a local minimum of an unconstrained multivariable function using a
derivative-free method.
Syntax:
x = fminsearch(fun, x0)
Description: Starts from the initial guess x0 and searches for a local minimum of the
function fun.
Arguments:
o fun: Function handle for the scalar-valued function to minimize.
o x0: Initial guess (vector for multivariable functions).
c) lsqnonneg
Purpose: Solves nonnegative linear least-squares problems.
Syntax:
x = lsqnonneg(C, d)
Description: Returns a vector x that minimizes norm(C*x - d) subject to x ≥ 0.
Arguments:
o C: Coefficient matrix.
o d: Right-hand side vector.
d) linprog
Purpose: Solves linear programming problems.
Syntax:
x = linprog(f, A, b, Aeq, beq, lb, ub, x0, options)
Description: Minimizes f'x subject to linear constraints.
Arguments:
o f: Coefficient vector for the objective function.
o A, b: Coefficients for inequality constraints (A*x ≤ b).
o Aeq, beq: Coefficients for equality constraints (Aeq*x = beq).
o lb, ub: Bounds for variables (lb ≤ x ≤ ub).
o x0: Initial guess (optional).
o options: Optimization options (optional).
e) quadprog
Purpose: Solves quadratic programming problems.
Syntax:
x = quadprog(H, f, A, b, Aeq, beq, lb, ub, x0, options)
Description: Minimizes (1/2)*x'Hx + f'x subject to constraints.
Arguments:
o H: Symmetric matrix for quadratic terms.
o f: Coefficient vector for linear terms.
o A, b: Coefficients for inequality constraints.
o Aeq, beq: Coefficients for equality constraints.
o lb, ub: Bounds for variables.
o x0: Initial guess (optional).
o options: Optimization options (optional).
f) lsqlin
Purpose: Solves constrained linear least-squares problems.
Syntax:
x = lsqlin(C, d, A, b, Aeq, beq, lb, ub, x0, options)
Description: Minimizes norm(C*x - d) subject to constraints.
Arguments:
o C, d: Coefficients for the least-squares problem.
o A, b: Inequality constraint coefficients.
o Aeq, beq: Equality constraint coefficients.
o lb, ub: Bounds for variables.
o x0: Initial guess (optional).
o options: Optimization options (optional).
2) Equation Solvers
a) fzero
Purpose: Finds roots of a nonlinear function.
Syntax:
x = fzero(fun, x0)
Description: Attempts to find a value of x where fun(x) = 0, i.e., where the function changes
sign.
Arguments:
o fun: Function handle for the scalar-valued function.
o x0: Initial guess or bracketing interval [x1, x2].
b) fsolve
Purpose: Solves systems of nonlinear equations.
Syntax:
x = fsolve(fun, x0, options)
Description: Finds the vector x such that fun(x) = 0.
Arguments:
o fun: Function handle for the system of equations.
o x0: Initial guess for the solution.
o options: Optimization options (optional).
3) Output Controllers
a) optimget
Purpose: Retrieves values of optimization options.
Syntax:
val = optimget(options, 'param')
Description: Returns the value of a specific parameter 'param' from the options structure.
Arguments:
o options: Optimization options structure.
o 'param': Name of the parameter to retrieve.
b) optimset
Purpose: Creates or modifies an optimization options structure.
Syntax:
options = optimset(Name, Value)
Description: Returns an options structure with specified parameters set using name-value
pairs.
Arguments:
o Name: Parameter name.
o Value: Value to assign to the parameter.
c) outputfcn
Purpose: Monitors optimization progress.
Syntax:
options = optimset('OutputFcn', @myfun)
Description: Sets a user-defined function (@myfun) to track optimization progress during
execution.
Arguments:
o @myfun: Function handle for custom output behavior.