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

📄 mcctest.c

📁 MATLAB扩展编程by 孙永康.ZIP.有需要的朋友请来下载.
💻 C
字号:
/*
 * MATLAB Compiler: 2.1
 * Date: Wed Oct 24 01:08:00 2001
 * 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" "mcctest.m" 
 */
#include "mcctest.h"
#include "libmatlbm.h"

static mxChar _array1_[132] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ',
                                'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i',
                                'l', 'e', ':', ' ', 'm', 'c', 'c', 't', 'e',
                                's', 't', ' ', 'L', 'i', 'n', 'e', ':', ' ',
                                '1', ' ', 'C', 'o', 'l', 'u', 'm', 'n', ':',
                                ' ', '1', ' ', 'T', 'h', 'e', ' ', 'f', 'u',
                                'n', 'c', 't', 'i', 'o', 'n', ' ', '"', 'm',
                                'c', 'c', 't', 'e', 's', 't', '"', ' ', 'w',
                                'a', 's', ' ', 'c', 'a', 'l', 'l', 'e', 'd',
                                ' ', 'w', 'i', 't', 'h', ' ', 'm', 'o', 'r',
                                'e', ' ', 't', 'h', 'a', 'n', ' ', 't', 'h',
                                'e', ' ', 'd', 'e', 'c', 'l', 'a', 'r', 'e',
                                'd', ' ', 'n', 'u', 'm', 'b', 'e', 'r', ' ',
                                'o', 'f', ' ', 'o', 'u', 't', 'p', 'u', 't',
                                's', ' ', '(', '0', ')', '.' };
static mxArray * _mxarray0_;

static mxChar _array3_[131] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ',
                                'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i',
                                'l', 'e', ':', ' ', 'm', 'c', 'c', 't', 'e',
                                's', 't', ' ', 'L', 'i', 'n', 'e', ':', ' ',
                                '1', ' ', 'C', 'o', 'l', 'u', 'm', 'n', ':',
                                ' ', '1', ' ', 'T', 'h', 'e', ' ', 'f', 'u',
                                'n', 'c', 't', 'i', 'o', 'n', ' ', '"', 'm',
                                'c', 'c', 't', 'e', 's', 't', '"', ' ', 'w',
                                'a', 's', ' ', 'c', 'a', 'l', 'l', 'e', 'd',
                                ' ', 'w', 'i', 't', 'h', ' ', 'm', 'o', 'r',
                                'e', ' ', 't', 'h', 'a', 'n', ' ', 't', 'h',
                                'e', ' ', 'd', 'e', 'c', 'l', 'a', 'r', 'e',
                                'd', ' ', 'n', 'u', 'm', 'b', 'e', 'r', ' ',
                                'o', 'f', ' ', 'i', 'n', 'p', 'u', 't', 's',
                                ' ', '(', '0', ')', '.' };
static mxArray * _mxarray2_;
static mxArray * _mxarray4_;
static mxArray * _mxarray5_;
static mxArray * _mxarray6_;
static mxArray * _mxarray7_;

static mxChar _array9_[22] = { 'M', 'a', 'x', ' ', '=', ' ', '%', 'd',
                               ',', ' ', 'I', 'n', 'd', 'e', 'x', ' ',
                               '=', ' ', '%', 'd', 0x005c, 'n' };
static mxArray * _mxarray8_;

void InitializeModule_mcctest(void) {
    _mxarray0_ = mclInitializeString(132, _array1_);
    _mxarray2_ = mclInitializeString(131, _array3_);
    _mxarray4_ = mclInitializeDouble(256.0);
    _mxarray5_ = mclInitializeDouble(1.0);
    _mxarray6_ = mclInitializeDouble(50.26548245743669);
    _mxarray7_ = mclInitializeDouble(2.0);
    _mxarray8_ = mclInitializeString(22, _array9_);
}

void TerminateModule_mcctest(void) {
    mxDestroyArray(_mxarray8_);
    mxDestroyArray(_mxarray7_);
    mxDestroyArray(_mxarray6_);
    mxDestroyArray(_mxarray5_);
    mxDestroyArray(_mxarray4_);
    mxDestroyArray(_mxarray2_);
    mxDestroyArray(_mxarray0_);
}

static void Mmcctest(void);

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

/*
 * The function "mlfMcctest" contains the normal interface for the "mcctest"
 * M-function from file "d:\book\soft\ch9\mcctest.m" (lines 1-8). This function
 * processes any input arguments and passes them to the implementation version
 * of the function, appearing above.
 */
void mlfMcctest(void) {
    mlfEnterNewContext(0, 0);
    Mmcctest();
    mlfRestorePreviousContext(0, 0);
}

/*
 * The function "mlxMcctest" contains the feval interface for the "mcctest"
 * M-function from file "d:\book\soft\ch9\mcctest.m" (lines 1-8). The feval
 * function calls the implementation version of mcctest through this function.
 * This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
void mlxMcctest(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    if (nlhs > 0) {
        mlfError(_mxarray0_);
    }
    if (nrhs > 0) {
        mlfError(_mxarray2_);
    }
    mlfEnterNewContext(0, 0);
    Mmcctest();
    mlfRestorePreviousContext(0, 0);
}

/*
 * The function "Mmcctest" is the implementation version of the "mcctest"
 * M-function from file "d:\book\soft\ch9\mcctest.m" (lines 1-8). 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 mcctest()
 */
static void Mmcctest(void) {
    mexLocalFunctionTable save_local_function_table_ = mclSetCurrentLocalFunctionTable(
                                                         &_local_function_table_mcctest);
    mxArray * ans = mclGetUninitializedArray();
    mxArray * i = mclGetUninitializedArray();
    mxArray * m = mclGetUninitializedArray();
    mxArray * y = mclGetUninitializedArray();
    mxArray * x = mclGetUninitializedArray();
    mxArray * n = mclGetUninitializedArray();
    /*
     * 
     * n = 256;
     */
    mlfAssign(&n, _mxarray4_);
    /*
     * x = sin([1:n]/n*(16*pi));
     */
    mlfAssign(
      &x,
      mlfSin(
        mclMtimes(
          mclMrdivide(mlfColon(_mxarray5_, mclVv(n, "n"), NULL), mclVv(n, "n")),
          _mxarray6_)));
    /*
     * y = abs(fft(x));
     */
    mlfAssign(&y, mlfAbs(mclVe(mlfFft(mclVv(x, "x"), NULL, NULL))));
    /*
     * y = y(1:n/2);
     */
    mlfAssign(
      &y,
      mclArrayRef1(
        mclVsv(y, "y"),
        mlfColon(_mxarray5_, mclMrdivide(mclVv(n, "n"), _mxarray7_), NULL)));
    /*
     * [m i] = max(y);
     */
    mlfAssign(&m, mlfMax(&i, mclVv(y, "y"), NULL, NULL));
    /*
     * fprintf('Max = %d, Index = %d\n', m, i);
     */
    mclAssignAns(
      &ans, mlfNFprintf(0, _mxarray8_, mclVv(m, "m"), mclVv(i, "i"), NULL));
    mxDestroyArray(n);
    mxDestroyArray(x);
    mxDestroyArray(y);
    mxDestroyArray(m);
    mxDestroyArray(i);
    mxDestroyArray(ans);
    mclSetCurrentLocalFunctionTable(save_local_function_table_);
}

⌨️ 快捷键说明

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