⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch2example16sfun.c

📁 清华大学出版社 邵玉斌编写的《通信系统建模与仿真实例分析》一书的所有MATLAB和SIMULINK代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*
 * MATLAB Compiler: 3.0
 * Date: Wed Jun 27 13:19:37 2007
 * Arguments: "-B" "macro_default" "-O" "all" "-O" "fold_scalar_mxarrays:on"
 * "-O" "fold_non_scalar_mxarrays:on" "-O" "optimize_integer_for_loops:on" "-O"
 * "array_indexing:on" "-O" "optimize_conditionals:on" "-x" "-W" "mex" "-L" "C"
 * "-t" "-T" "link:mexlibrary" "libmatlbmx.mlib" "ch2example16Sfun.m" 
 */
#include "ch2example16sfun.h"
#include "libmatlbm.h"
#include "num2str.h"
#include "simsizes.h"

static double _array1_[9] = { 0.0, 0.0, -4.0, 1.0, 0.0, -6.0, 0.0, 1.0, -3.0 };
static mxArray * _mxarray0_;

static double _array3_[3] = { 0.0, 0.0, 1.0 };
static mxArray * _mxarray2_;

static double _array5_[3] = { 0.0, 4.0, 0.0 };
static mxArray * _mxarray4_;
static mxArray * _mxarray6_;
static mxArray * _mxarray7_;
static mxArray * _mxarray8_;
static mxArray * _mxarray11_;
static mxArray * _mxarray12_;
static mxArray * _mxarray13_;

static mxArray * _array10_[3] = { NULL /*_mxarray11_*/, NULL /*_mxarray12_*/,
                                  NULL /*_mxarray13_*/ };
static mxArray * _mxarray9_;
static mxArray * _mxarray14_;

static mxChar _array16_[17] = { 'U', 'n', 'h', 'a', 'n', 'd', 'l', 'e', 'd',
                                ' ', 'f', 'l', 'a', 'g', ' ', '=', ' ' };
static mxArray * _mxarray15_;

static double _array18_[3] = { 0.0, 0.0, 0.0 };
static mxArray * _mxarray17_;

static double _array20_[2] = { 0.0, 0.0 };
static mxArray * _mxarray19_;

void InitializeModule_ch2example16sfun(void) {
    _mxarray0_ = mclInitializeDoubleVector(3, 3, _array1_);
    _mxarray2_ = mclInitializeDoubleVector(3, 1, _array3_);
    _mxarray4_ = mclInitializeDoubleVector(1, 3, _array5_);
    _mxarray6_ = mclInitializeDouble(0.0);
    _mxarray7_ = mclInitializeDouble(1.0);
    _mxarray8_ = mclInitializeDouble(3.0);
    _mxarray11_ = mclInitializeDouble(2.0);
    _array10_[0] = _mxarray11_;
    _mxarray12_ = mclInitializeDouble(4.0);
    _array10_[1] = _mxarray12_;
    _mxarray13_ = mclInitializeDouble(9.0);
    _array10_[2] = _mxarray13_;
    _mxarray9_ = mclInitializeCellVector(1, 3, _array10_);
    _mxarray14_ = mclInitializeDoubleVector(0, 0, (double *)NULL);
    _mxarray15_ = mclInitializeString(17, _array16_);
    _mxarray17_ = mclInitializeDoubleVector(3, 1, _array18_);
    _mxarray19_ = mclInitializeDoubleVector(1, 2, _array20_);
}

void TerminateModule_ch2example16sfun(void) {
    mxDestroyArray(_mxarray19_);
    mxDestroyArray(_mxarray17_);
    mxDestroyArray(_mxarray15_);
    mxDestroyArray(_mxarray14_);
    mxDestroyArray(_mxarray9_);
    mxDestroyArray(_mxarray13_);
    mxDestroyArray(_mxarray12_);
    mxDestroyArray(_mxarray11_);
    mxDestroyArray(_mxarray8_);
    mxDestroyArray(_mxarray7_);
    mxDestroyArray(_mxarray6_);
    mxDestroyArray(_mxarray4_);
    mxDestroyArray(_mxarray2_);
    mxDestroyArray(_mxarray0_);
}

static mxArray * mlfCh2example16sfun_mdlInitializeSizes(mxArray * * x0,
                                                        mxArray * * str,
                                                        mxArray * * ts,
                                                        mxArray * A,
                                                        mxArray * B,
                                                        mxArray * C,
                                                        mxArray * D);
static void mlxCh2example16sfun_mdlInitializeSizes(int nlhs,
                                                   mxArray * plhs[],
                                                   int nrhs,
                                                   mxArray * prhs[]);
static mxArray * mlfCh2example16sfun_mdlDerivatives(mxArray * t,
                                                    mxArray * x,
                                                    mxArray * u,
                                                    mxArray * A,
                                                    mxArray * B,
                                                    mxArray * C,
                                                    mxArray * D);
static void mlxCh2example16sfun_mdlDerivatives(int nlhs,
                                               mxArray * plhs[],
                                               int nrhs,
                                               mxArray * prhs[]);
static mxArray * mlfCh2example16sfun_mdlOutputs(mxArray * t,
                                                mxArray * x,
                                                mxArray * u,
                                                mxArray * A,
                                                mxArray * B,
                                                mxArray * C,
                                                mxArray * D);
static void mlxCh2example16sfun_mdlOutputs(int nlhs,
                                           mxArray * plhs[],
                                           int nrhs,
                                           mxArray * prhs[]);
static mxArray * Mch2example16sfun(mxArray * * x0,
                                   mxArray * * str,
                                   mxArray * * ts,
                                   int nargout_,
                                   mxArray * t,
                                   mxArray * x,
                                   mxArray * u,
                                   mxArray * flag);
static mxArray * Mch2example16sfun_mdlInitializeSizes(mxArray * * x0,
                                                      mxArray * * str,
                                                      mxArray * * ts,
                                                      int nargout_,
                                                      mxArray * A,
                                                      mxArray * B,
                                                      mxArray * C,
                                                      mxArray * D);
static mxArray * Mch2example16sfun_mdlDerivatives(int nargout_,
                                                  mxArray * t,
                                                  mxArray * x,
                                                  mxArray * u,
                                                  mxArray * A,
                                                  mxArray * B,
                                                  mxArray * C,
                                                  mxArray * D);
static mxArray * Mch2example16sfun_mdlOutputs(int nargout_,
                                              mxArray * t,
                                              mxArray * x,
                                              mxArray * u,
                                              mxArray * A,
                                              mxArray * B,
                                              mxArray * C,
                                              mxArray * D);

static mexFunctionTableEntry local_function_table_[3]
  = { { "mdlInitializeSizes",
        mlxCh2example16sfun_mdlInitializeSizes, 4, 4, NULL },
      { "mdlDerivatives", mlxCh2example16sfun_mdlDerivatives, 7, 1, NULL },
      { "mdlOutputs", mlxCh2example16sfun_mdlOutputs, 7, 1, NULL } };

_mexLocalFunctionTable _local_function_table_ch2example16sfun
  = { 3, local_function_table_ };

/*
 * The function "mlfCh2example16sfun" contains the normal interface for the
 * "ch2example16sfun" M-function from file
 * "d:\syb\after20060609\清华大学出版社约稿\写作初稿\prog\ch2example16sfun.m"
 * (lines 1-25). This function processes any input arguments and passes them to
 * the implementation version of the function, appearing above.
 */
mxArray * mlfCh2example16sfun(mxArray * * x0,
                              mxArray * * str,
                              mxArray * * ts,
                              mxArray * t,
                              mxArray * x,
                              mxArray * u,
                              mxArray * flag) {
    int nargout = 1;
    mxArray * sys = NULL;
    mxArray * x0__ = NULL;
    mxArray * str__ = NULL;
    mxArray * ts__ = NULL;
    mlfEnterNewContext(3, 4, x0, str, ts, t, x, u, flag);
    if (x0 != NULL) {
        ++nargout;
    }
    if (str != NULL) {
        ++nargout;
    }
    if (ts != NULL) {
        ++nargout;
    }
    sys = Mch2example16sfun(&x0__, &str__, &ts__, nargout, t, x, u, flag);
    mlfRestorePreviousContext(3, 4, x0, str, ts, t, x, u, flag);
    if (x0 != NULL) {
        mclCopyOutputArg(x0, x0__);
    } else {
        mxDestroyArray(x0__);
    }
    if (str != NULL) {
        mclCopyOutputArg(str, str__);
    } else {
        mxDestroyArray(str__);
    }
    if (ts != NULL) {
        mclCopyOutputArg(ts, ts__);
    } else {
        mxDestroyArray(ts__);
    }
    return mlfReturnValue(sys);
}

/*
 * The function "mlxCh2example16sfun" contains the feval interface for the
 * "ch2example16sfun" M-function from file
 * "d:\syb\after20060609\清华大学出版社约稿\写作初稿\prog\ch2example16sfun.m"
 * (lines 1-25). The feval function calls the implementation version of
 * ch2example16sfun through this function. This function processes any input
 * arguments and passes them to the implementation version of the function,
 * appearing above.
 */
void mlxCh2example16sfun(int nlhs,
                         mxArray * plhs[],
                         int nrhs,
                         mxArray * prhs[]) {
    mxArray * mprhs[4];
    mxArray * mplhs[4];
    int i;
    if (nlhs > 4) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: ch2example16sfun Line: 1 Colum"
            "n: 1 The function \"ch2example16sfun\" was called wi"
            "th more than the declared number of outputs (4)."),
          NULL);
    }
    if (nrhs > 4) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: ch2example16sfun Line: 1 Colu"
            "mn: 1 The function \"ch2example16sfun\" was called "
            "with more than the declared number of inputs (4)."),
          NULL);
    }
    for (i = 0; i < 4; ++i) {
        mplhs[i] = NULL;
    }
    for (i = 0; i < 4 && i < nrhs; ++i) {
        mprhs[i] = prhs[i];
    }
    for (; i < 4; ++i) {
        mprhs[i] = NULL;
    }
    mlfEnterNewContext(0, 4, mprhs[0], mprhs[1], mprhs[2], mprhs[3]);
    mplhs[0]
      = Mch2example16sfun(
          &mplhs[1],
          &mplhs[2],
          &mplhs[3],
          nlhs,
          mprhs[0],
          mprhs[1],
          mprhs[2],
          mprhs[3]);
    mlfRestorePreviousContext(0, 4, mprhs[0], mprhs[1], mprhs[2], mprhs[3]);
    plhs[0] = mplhs[0];
    for (i = 1; i < 4 && i < nlhs; ++i) {
        plhs[i] = mplhs[i];
    }
    for (; i < 4; ++i) {
        mxDestroyArray(mplhs[i]);
    }
}

/*
 * The function "mlfCh2example16sfun_mdlInitializeSizes" contains the normal
 * interface for the "ch2example16sfun/mdlInitializeSizes" M-function from file
 * "d:\syb\after20060609\清华大学出版社约稿\写作初稿\prog\ch2example16sfun.m"
 * (lines 25-40). This function processes any input arguments and passes them
 * to the implementation version of the function, appearing above.
 */
static mxArray * mlfCh2example16sfun_mdlInitializeSizes(mxArray * * x0,
                                                        mxArray * * str,
                                                        mxArray * * ts,
                                                        mxArray * A,
                                                        mxArray * B,
                                                        mxArray * C,
                                                        mxArray * D) {
    int nargout = 1;
    mxArray * sys = NULL;
    mxArray * x0__ = NULL;
    mxArray * str__ = NULL;
    mxArray * ts__ = NULL;
    mlfEnterNewContext(3, 4, x0, str, ts, A, B, C, D);
    if (x0 != NULL) {
        ++nargout;
    }
    if (str != NULL) {
        ++nargout;
    }
    if (ts != NULL) {
        ++nargout;
    }
    sys
      = Mch2example16sfun_mdlInitializeSizes(
          &x0__, &str__, &ts__, nargout, A, B, C, D);
    mlfRestorePreviousContext(3, 4, x0, str, ts, A, B, C, D);
    if (x0 != NULL) {
        mclCopyOutputArg(x0, x0__);
    } else {
        mxDestroyArray(x0__);
    }
    if (str != NULL) {
        mclCopyOutputArg(str, str__);
    } else {
        mxDestroyArray(str__);
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -