MATLAB Examples

Perform nonlinear fitting of complex-valued data. While most Optimization Toolbox™ solvers and algorithms operate only on real-valued data, least-squares solvers and fsolve can work on

Fit a nonlinear function to data using several Optimization Toolbox™ algorithms.

Recover a blurred image by solving a large-scale bound-constrained linear least-squares optimization problem.

Fit parameters of an ODE to data in two ways. The first shows a straightforward fit of a constant-speed circular path to a portion of a solution of the Lorenz system, a famous ODE with sensitive

Use the problem-based approach to solve an investment problem with deterministic returns over a fixed number of years T . The problem is to allocate your money over available investments to

Create a multiperiod inventory model in the problem-based framework. The problem is to schedule production of fertilizer blends over a period of time using a variety of ingredients whose

Create an initial point for an optimization problem that has named index variables. For named index variables, often the easiest way to specify an initial point is to use the findindex

Optimization variables can use names for indexing elements. You can give the names when you create a variable or afterward. For example, give the names while creating the variable.

You can create and debug some problems easily by using named index variables. For example, consider the variable x that is indexed by the names in vars :

Set up and solve a mixed-integer linear programming problem. The problem is to find the optimal production and distribution levels among a set of factories, warehouses, and sales outlets.

Solve a Sudoku puzzle using binary integer programming. For the problem-based approach, see Solve Sudoku Puzzles Via Integer Programming: Problem-Based .

Solve an assignment problem by binary integer programming using the intlinprog function. For the problem-based approach to this problem, see Office Assignments by Binary Integer

Solve a Mixed-Integer Quadratic Programming (MIQP) portfolio optimization problem using the intlinprog Mixed-Integer Linear Programming (MILP) solver. The idea is to iteratively

Solve a cutting stock problem using linear programming with an integer linear programming subroutine. The example uses the solver-based approach. For the problem-based approach, see

Use the linprog solver in Optimization Toolbox® to solve an investment problem with deterministic returns over a fixed number of years T . The problem is to allocate your money over available

Schedule two gas-fired electric generators optimally, meaning to get the most revenue minus cost. While the example is not entirely realistic, it does show how to take into account costs

Use binary integer programming to solve the classic traveling salesman problem. This problem involves finding the shortest closed tour (path) through a set of stops (cities). In this case

Solve a Sudoku puzzle using binary integer programming. For the solver-based approach, see Solve Sudoku Puzzles Via Integer Programming: Solver-Based .

Solve a Mixed-Integer Quadratic Programming (MIQP) portfolio optimization problem using the problem-based approach. The idea is to iteratively solve a sequence of mixed-integer linear

Solve an assignment problem by binary integer programming using the optimization problem approach. For the solver-based approach, see Office Assignments by Binary Integer Programming:

Solve a cutting stock problem using linear programming with an integer linear programming subroutine. The example uses the problem-based approach. For the solver-based approach, see

Solve a nonlinear filter design problem using a minimax optimization algorithm, fminimax , in Optimization Toolbox™. Note that to run this example you must have the Signal Processing

Solve a pole-placement problem using the multiobjective goal attainment method. This algorithm is implemented in the function fgoalattain .

Use the Symbolic Math Toolbox™ functions named jacobian and matlabFunction to provide derivatives to optimization solvers. Optimization Toolbox™ solvers are usually more accurate and

Minimize Rosenbrock's "banana function":

Use semi-infinite programming to investigate the effect of uncertainty in the model parameters of an optimization problem. We will formulate and solve an optimization problem using the

This example was authored by the MathWorks community.

Solve portfolio optimization problems using the interior-point quadratic programming algorithm in quadprog. The function quadprog belongs to Optimization Toolbox™.

Determine the shape of a circus tent by solving a large-scale quadratic optimization problem. The shape of a circus tent is determined by a constrained optimization problem. We will solve

The value of using sparse arithmetic when you have a sparse problem. The matrix has n rows, where you choose n to be a large value, and a few nonzero diagonal bands. A full matrix of size n -by- n can

How to speed up the minimization of an expensive optimization problem using functions in Optimization Toolbox™ and Global Optimization Toolbox. In the first part of the example we solve the

Use two nonlinear optimization solvers and how to set options. The nonlinear solvers that we use in this example are fminunc and fmincon .

This examples illustrates how to perform a FORM analysis on a discrete (0 or 1) failure response. In the example we'll compare a traditional Monte Carlo method with FORM. This example is was

We propose two fuzzy portfolio optimization models based on the Markowitz Mean-Variance approach. The first model involves trapezoidal fuzzy numbers to extent statistical data, which

This demo was adapted from a 2009 digest article: Improving Optimization Performance with Parallel Computing

Time series of acceleration records are simulated using a stationnary process that is "weighted" by an envelopp function. The function that fullfills this procedure is 'seismSim'.

This code is an applicatino of EMOO by using Genetic algorithms to solve the following simple constrained problem: Draw the biggest possible circle in a 2D space filled with stars without

Choose your country to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a location from the following list:

See all countries