文档

ssGetContStates

获取一个块的连续状态

语法

real_T *ssGetContStates(SimStruct *S)

参数

年代

SimStruct表示一个S-Function块。

返回

指针(real_T *)到连续状态向量作为长度数组ssGetNumContStates (S).返回如果s函数没有任何连续状态。

描述

在模拟循环中使用,mdlInitializeConditions,或mdlStart例程来获得real_Ts函数的连续状态向量。这个向量有长度ssGetNumContStates (S).通常,这个向量初始化在mdlInitializeConditions并用于mdlOutputs

语言

C, c++

例子

下面几行来自该文件csfunc.c中初始化连续状态mdlInitializeConditions然后计算状态导数mdlDerivatives.模型中使用了这个s函数sfcndemo_csfunc

static void mdlInitializeConditions(SimStruct *S) {real_T *x0 = ssGetContStates(S);int_T lp;For (lp=0;lp<2;lp++) {*x0++=0.0;}} static void mdlDerivatives(SimStruct *S) {real_T *dx = ssGetdX(S);real_T *x = ssGetContStates(S);InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S,0);/ * xdot = Ax + Bu * / dx [0] = [0] [0] * x [0] + [1] [1] B * x [1] + [0] [0] * U (0) + B [0] [1] * U (1);dx [1] = [1] [0] * x [0] + [1] [1] B * x [1] + [1] [0] * U (0) + B [1] [1] * U (1);}

R2006a之前介绍