Main Content

本页的翻译已过时。点击此处可查看最新英文版本。

线性最小二乘

求解具有边界或线性约束的线性最小二乘问题

在开始求解优化问题之前,您必须选择合适的方法:基于问题或基于求解器。有关详细信息,请参阅首先选择基于问题或基于求解器的方法

线性最小二乘求解 min||C*x - d||2,可能有边界或线性约束。

对于基于问题的方法,请创建问题变量,然后用这些符号变量表示目标函数和约束。有关基于问题的求解步骤,请参阅Problem-Based Optimization Workflow。要求解生成的问题,请使用 solve

有关基于求解器的求解步骤,包括定义目标函数和约束,以及选择合适的求解器,请参阅基于求解器的优化问题设置。要求解生成的问题,请使用 lsqlin;或者,对于非负最小二乘,也可以使用 lsqnonneg

函数

全部展开

evaluate计算优化表达式
infeasibility一个点处的约束违反度
optimproblem创建优化问题
optimvar创建优化变量
solve求解优化问题或方程问题
lsqlin求解约束线性最小二乘问题
lsqnonneg求解非负线性最小二乘问题
mldivide, \求解关于 x 的线性方程组 Ax = B
optimwarmstartCreate warm start object

实时编辑器任务

优化在实时编辑器中优化或求解方程

主题

基于问题的线性最小二乘

Shortest Distance to a Plane

Shows how to solve a linear least-squares problem using the problem-based approach.

Nonnegative Linear Least Squares, Problem-Based

Shows how to solve a nonnegative linear least-squares problem using the problem-based approach and several solvers.

Large-Scale Constrained Linear Least-Squares, Problem-Based

Solves an optical deblurring problem using the problem-based approach.

Write Objective Function for Problem-Based Least Squares

Syntax rules for problem-based least squares.

基于求解器的线性最小二乘

Optimize Live Editor Task with lsqlin Solver

Example showing the Optimize Live Editor task and linear least squares.

Nonnegative Linear Least Squares, Solver-Based

This example shows how to use several algorithms to solve a linear least-squares problem with the bound constraint that the solution is nonnegative.

Jacobian Multiply Function with Linear Least Squares

Example showing how to save memory in a large structured linear least-squares problem.

Warm Start Best Practices

Describes how best to use warm start for speeding repeated solutions.

Large-Scale Constrained Linear Least-Squares, Solver-Based

Solves an optical deblurring problem using the solver-based approach.

代码生成

Code Generation in Linear Least Squares: Background

Prerequisites to generate C code for linear least squares.

Generate Code for lsqlin

Example of code generation for linear least squares.

Optimization Code Generation for Real-Time Applications

Explore techniques for handling real-time requirements in generated code.

基于问题的算法

Write Objective Function for Problem-Based Least Squares

Syntax rules for problem-based least squares.

基于问题的优化算法

优化函数和对象如何求解优化问题。

Supported Operations for Optimization Variables and Expressions

Explore the supported mathematical and indexing operations for optimization variables and expressions.

算法和选项

最小二乘(模型拟合)算法

在仅具有边界或线性约束的情况下,在 n 个维度中最小化平方和。

优化选项参考

了解优化选项。