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

📄 test2.cpp

📁 利用VC++调用MATLAB中的函数进行函数绘图的实例
💻 CPP
字号:
//
// MATLAB Compiler: 3.0
// Date: Tue Dec 16 10:40:04 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" "-p" "-W" "main" "-L"
// "Cpp" "-t" "-T" "link:exe" "-h" "libmmfile.mlib" "-B" "sglcpp" "-p" "-W"
// "main" "-L" "Cpp" "-t" "-T" "link:exe" "-h" "libmmfile.mlib" "-W" "mainhg"
// "libmwsglm.mlib" "test2.m" 
//
#include "test2.hpp"
#include "libmatlbm.hpp"

static double _array1_[101] = { 0.0, .1, .2, .30000000000000004, .4, .5,
                                .6000000000000001, .7000000000000001, .8, .9,
                                1.0, 1.1, 1.2000000000000002, 1.3,
                                1.4000000000000001, 1.5, 1.6,
                                1.7000000000000002, 1.8, 1.9000000000000001,
                                2.0, 2.1, 2.2, 2.3000000000000003,
                                2.4000000000000004, 2.5, 2.6, 2.7,
                                2.8000000000000003, 2.9000000000000004, 3.0,
                                3.1, 3.2, 3.3000000000000003,
                                3.4000000000000004, 3.5, 3.6, 3.7,
                                3.8000000000000003, 3.9000000000000004, 4.0,
                                4.1000000000000005, 4.2, 4.3, 4.4, 4.5,
                                4.6000000000000005, 4.7, 4.800000000000001, 4.9,
                                5.0, 5.1, 5.199999999999999, 5.3,
                                5.3999999999999995, 5.5, 5.6, 5.7, 5.8,
                                5.8999999999999995, 6.0, 6.1, 6.199999999999999,
                                6.3, 6.4, 6.5, 6.6, 6.699999999999999, 6.8, 6.9,
                                7.0, 7.1, 7.199999999999999, 7.3, 7.4, 7.5, 7.6,
                                7.699999999999999, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3,
                                8.4, 8.5, 8.6, 8.7, 8.8, 8.9, 9.0, 9.1, 9.2,
                                9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9, 10.0 };
static mwArray _mxarray0_ = mclInitializeDoubleVector(1, 101, _array1_);

void InitializeModule_test2() {
}

void TerminateModule_test2() {
}

static void Mtest2();

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

//
// The function "test2" contains the normal interface for the "test2"
// M-function from file "c:\matlab6p5\work\test2.m" (lines 1-4). This function
// processes any input arguments and passes them to the implementation version
// of the function, appearing above.
//
void test2() {
    Mtest2();
}

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

//
// The function "Mtest2" is the implementation version of the "test2"
// M-function from file "c:\matlab6p5\work\test2.m" (lines 1-4). 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 test2
//
static void Mtest2() {
    mwLocalFunctionTable save_local_function_table_
      = &_local_function_table_test2;
    mwArray ans = mwArray::UNDEFINED;
    mwArray y = mwArray::UNDEFINED;
    mwArray x = mwArray::UNDEFINED;
    //
    // x=0:0.1:10;
    //
    x = _mxarray0_;
    //
    // y=sin(x);
    //
    y = sin(mwVv(x, "x"));
    //
    // plot(x,y);
    //
    ans.EqAns(Nplot(0, mwVarargin(mwVv(x, "x"), mwVv(y, "y"))));
}

⌨️ 快捷键说明

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