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

📄 test1.cpp

📁 利用VC++调用MATLAB中的函数进行函数绘图的实例
💻 CPP
字号:
//
// MATLAB Compiler: 3.0
// Date: Tue Dec 16 10:05:06 2008
// 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" "-t" "-L" "CPP" "-h"
// "test1.m" 
//
#include "test1.hpp"
#include "libmatlbm.hpp"
static mwArray _mxarray0_ = mclInitializeDouble(1.0);
static mwArray _mxarray1_ = mclInitializeDoubleVector(0, 0, (double *)NULL);

void InitializeModule_test1() {
}

void TerminateModule_test1() {
}

static mwArray Mtest1(int nargout_, mwArray n);

_mexLocalFunctionTable _local_function_table_test1
  = { 0, (mexFunctionTableEntry *)NULL };

//
// The function "test1" contains the normal interface for the "test1"
// M-function from file "c:\matlab6p5\work\test1.m" (lines 1-6). This function
// processes any input arguments and passes them to the implementation version
// of the function, appearing above.
//
mwArray test1(mwArray n) {
    int nargout = 1;
    mwArray y = mwArray::UNDEFINED;
    y = Mtest1(nargout, n);
    return y;
}

//
// The function "mlxTest1" contains the feval interface for the "test1"
// M-function from file "c:\matlab6p5\work\test1.m" (lines 1-6). The feval
// function calls the implementation version of test1 through this function.
// This function processes any input arguments and passes them to the
// implementation version of the function, appearing above.
//
void mlxTest1(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    MW_BEGIN_MLX();
    {
        mwArray mprhs[1];
        mwArray mplhs[1];
        int i;
        mclCppUndefineArrays(1, mplhs);
        if (nlhs > 1) {
            error(
              mwVarargin(
                mwArray(
                  "Run-time Error: File: test1 Line: 1 Column: 1"
                  " The function \"test1\" was called with more "
                  "than the declared number of outputs (1).")));
        }
        if (nrhs > 1) {
            error(
              mwVarargin(
                mwArray(
                  "Run-time Error: File: test1 Line: 1 Column: 1"
                  " The function \"test1\" was called with more "
                  "than the declared number of inputs (1).")));
        }
        for (i = 0; i < 1 && i < nrhs; ++i) {
            mprhs[i] = mwArray(prhs[i], 0);
        }
        for (; i < 1; ++i) {
            mprhs[i].MakeDIN();
        }
        mplhs[0] = Mtest1(nlhs, mprhs[0]);
        plhs[0] = mplhs[0].FreezeData();
    }
    MW_END_MLX();
}

//
// The function "Mtest1" is the implementation version of the "test1"
// M-function from file "c:\matlab6p5\work\test1.m" (lines 1-6). It contains
// the actual compiled code for that M-function. It is a static function and
// must only be called from one of the interface functions, appearing below.
//
//
// function y=test1(n)
//
static mwArray Mtest1(int nargout_, mwArray n) {
    mwLocalFunctionTable save_local_function_table_
      = &_local_function_table_test1;
    mwArray y = mwArray::UNDEFINED;
    mwArray i = mwArray::UNDEFINED;
    //
    // y=1;
    //
    y = _mxarray0_;
    //
    // for i=1:n
    //
    {
        int v_ = mclForIntStart(1);
        int e_ = mclForIntEnd(mwVa(n, "n"));
        if (v_ > e_) {
            i = _mxarray1_;
        } else {
            //
            // y=y*i;
            // end
            //
            for (; ; ) {
                y = mwVv(y, "y") * v_;
                if (v_ == e_) {
                    break;
                }
                ++v_;
            }
            i = v_;
        }
    }
    mwValidateOutput(y, 1, nargout_, "y", "test1");
    return y;
}

⌨️ 快捷键说明

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