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

📄 myfunct.c

📁 一个非常典型的”VC调用matlab中定义的.m文件中的函数的实例“附加说明文档
💻 C
字号:
/*
 * MATLAB Compiler: 3.0
 * Date: Tue Mar 30 14:10:41 2004
 * 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" "-h" "-L" "C" "-W"
 * "lib:ppp" "-T" "link:lib" "myfunct.m" 
 */
#include "myfunct.h"
#include "libmatlbm.h"

void InitializeModule_myfunct(void) {
}

void TerminateModule_myfunct(void) {
}

static mxArray * Mmyfunct(int nargout_, mxArray * a, mxArray * b);

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

/*
 * The function "mlfMyfunct" contains the normal interface for the "myfunct"
 * M-function from file "e:\vc_mat\myfunct.m" (lines 1-2). This function
 * processes any input arguments and passes them to the implementation version
 * of the function, appearing above.
 */
mxArray * mlfMyfunct(mxArray * a, mxArray * b) {
    int nargout = 1;
    mxArray * y = NULL;
    mlfEnterNewContext(0, 2, a, b);
    y = Mmyfunct(nargout, a, b);
    mlfRestorePreviousContext(0, 2, a, b);
    return mlfReturnValue(y);
}

/*
 * The function "mlxMyfunct" contains the feval interface for the "myfunct"
 * M-function from file "e:\vc_mat\myfunct.m" (lines 1-2). The feval function
 * calls the implementation version of myfunct through this function. This
 * function processes any input arguments and passes them to the implementation
 * version of the function, appearing above.
 */
void mlxMyfunct(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    mxArray * mprhs[2];
    mxArray * mplhs[1];
    int i;
    if (nlhs > 1) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: myfunct Line: 1 Column: "
            "1 The function \"myfunct\" was called with mor"
            "e than the declared number of outputs (1)."),
          NULL);
    }
    if (nrhs > 2) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: myfunct Line: 1 Column:"
            " 1 The function \"myfunct\" was called with m"
            "ore than the declared number of inputs (2)."),
          NULL);
    }
    for (i = 0; i < 1; ++i) {
        mplhs[i] = NULL;
    }
    for (i = 0; i < 2 && i < nrhs; ++i) {
        mprhs[i] = prhs[i];
    }
    for (; i < 2; ++i) {
        mprhs[i] = NULL;
    }
    mlfEnterNewContext(0, 2, mprhs[0], mprhs[1]);
    mplhs[0] = Mmyfunct(nlhs, mprhs[0], mprhs[1]);
    mlfRestorePreviousContext(0, 2, mprhs[0], mprhs[1]);
    plhs[0] = mplhs[0];
}

/*
 * The function "Mmyfunct" is the implementation version of the "myfunct"
 * M-function from file "e:\vc_mat\myfunct.m" (lines 1-2). 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 = add_zh(a,b)
 */
static mxArray * Mmyfunct(int nargout_, mxArray * a, mxArray * b) {
    mexLocalFunctionTable save_local_function_table_
      = mclSetCurrentLocalFunctionTable(&_local_function_table_myfunct);
    mxArray * y = NULL;
    mclCopyArray(&a);
    mclCopyArray(&b);
    /*
     * y=a+b
     */
    mlfAssign(&y, mclPlus(mclVa(a, "a"), mclVa(b, "b")));
    mclPrintArray(mclVv(y, "y"), "y");
    mclValidateOutput(y, 1, nargout_, "y", "myfunct");
    mxDestroyArray(b);
    mxDestroyArray(a);
    mclSetCurrentLocalFunctionTable(save_local_function_table_);
    return y;
}

⌨️ 快捷键说明

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