State Space
ContinuousStateSpace 模块实现采用矩阵状态空间形式表述的通用连续时间线性定常(LTI)动态系统。通过内部状态向量()、控制输入向量()与测量输出向量()对物理受控对象进行统一建模,它是现代控制理论、多变量(MIMO)系统设计、卡尔曼滤波、线性二次型调节器(LQR)以及结构模态分析的基础基石。模块全面支持标准 MATLAB/矩阵语法(分号分隔行),原生支持多输入多输出,并通过 WebAssembly 高阶数值求解器解算连续状态轨迹。
数学模型
连续时间状态空间系统由一阶向量微分状态方程与代数测量方程共同定义:
其中:
- 为 维内部状态向量
- 为 维外部输入向量
- 为 维测量输出向量
- 为系统状态转移矩阵
- 为输入控制矩阵
- 为输出观测矩阵
- 为直接前馈传递矩阵
矩阵 的特征值决定了系统的特征极点:
系统渐近稳定的充要条件是矩阵 的所有特征值均具有严格负实部()。在频域中,对应的等效 传递函数矩阵计算如下:
输入与输出
| Direction | ID | Label | 类型 | Status |
|---|---|---|---|---|
| → In | u |
Input(s) | number | Required |
| → In | reset |
Reset | number | Optional |
| ← Out | y |
Output(s) | number | Output |
参数
| 参数 | Label | 类型 | 默认值 | 描述 |
|---|---|---|---|---|
A |
A Matrix (state) | matrix | -1 |
|
B |
B Matrix (input) | matrix | 1 |
|
C |
C Matrix (output) | matrix | 1 |
|
D |
D Matrix (feedthrough) | vector | 0 |
|
initialState |
Initial State (comma-sep) | vector | 0 |
使用示例
示例 1:小车倒立摆线性化状态空间模型
在倒立摆直立不稳定平衡点附近对其进行线性化建模,状态向量为 。配置 A = "0 1 0 0; 0 -0.1 2.5 0; 0 0 0 1; 0 -0.2 28.5 0", B = "0; 1.5; 0; 3.0", C = "1 0 0 0; 0 0 1 0"(同时测量小车位置与摆杆角位移),D = "0; 0", initialState = "0, 0, 0.05, 0"。由此可直接检验状态反馈镇定控制器()在 初始倾角下的闭环控制效果。
示例 2:双惯量扭转弹性驱动轴动力学仿真
建模电机与负载之间的弹性转轴扭转振荡,状态变量分别取电机转速、负载转速及转轴相对扭角。设置 A = "-0.2 0 -5; 0 -0.1 5; 1 -1 0", B = "1; 0; 0", C = "0 1 0", D = "0"。该模型精准复现了电机启动阶跃过程中轴系的扭转共振衰减与动态扭矩传递。
说明与最佳实践
- 矩阵维度严格匹配规则:各矩阵维度必须在代数上完全自洽:若 为 ,则 必须为 , 为 , 为 。维度不一致将在编译时触发错误。
- 多变量 (MIMO) 自动拓扑自适应:模块输入端口数自动根据 的列数扩展,输出端口数自动匹配 的行数。
- 高阶刚性 ODE 求解器适配:在底座 Rust 内核中通过 RK4、RK45 显式求解器以及针对宽频刚性矩阵的 TR-BDF2 隐式求解器进行求解,确保高度数值稳定性。
- 外部复位端口能力:向可选的
reset端口输入有效正电平信号时,状态向量 将立即重置为initialState中定义的初始状态。
常见工程问题解答 (FAQ)
Q: How to select weighting matrices Q and R for Linear Quadratic Regulator (LQR)?
Use Bryson's Rule as an engineering baseline: set diagonal elements to and , where is the maximum acceptable deviation for state and is the maximum actuator excursion. This normalizes all state penalties and control efforts to non-dimensional units, allowing intuitive trade-offs between response speed and actuator effort.
Q: How does State-Space compare to Transfer Function representation?
Transfer functions describe single-input single-output (SISO) input-output dynamics under zero initial conditions, hiding internal plant dynamics. State-Space models () naturally handle multi-input multi-output (MIMO) systems, non-zero initial conditions, and internal observability and controllability structures.
相关模块
- TransferFunction: 单输入单输出(SISO)多项式传递函数 。
- ZeroPole: 零极点增益因式分解形式 。
- Integrator: 连续时间单状态 动态积分器。
- SecondOrderSystem: 标准二阶连续振荡器环节。