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

📄 sgltest1.cpp

📁 绘图函数用mcc生成的代码嵌入VC工程实例
💻 CPP
字号:
//
// MATLAB Compiler: 2.1
// Date: Fri Oct 26 10:24:04 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" "-B" "sglcpp" "-p" "-W"
// "main" "-L" "Cpp" "-t" "-T" "link:exe" "-h" "libmmfile.mlib" "-W" "mainhg"
// "libmwsglm.mlib" "sgltest1" 
//
#include "sgltest1.hpp"
#include "libmatlbm.hpp"
#include "libmmfile.hpp"
#include "libmwsglm.hpp"
#include "subplot.hpp"

static mxChar _array1_[134] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ',
                                'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i',
                                'l', 'e', ':', ' ', 's', 'g', 'l', 't', 'e',
                                's', 't', '1', ' ', 'L', 'i', 'n', 'e', ':',
                                ' ', '1', ' ', 'C', 'o', 'l', 'u', 'm', 'n',
                                ':', ' ', '1', ' ', 'T', 'h', 'e', ' ', 'f',
                                'u', 'n', 'c', 't', 'i', 'o', 'n', ' ', '"',
                                's', 'g', 'l', 't', 'e', 's', 't', '1', '"',
                                ' ', '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 mwArray _mxarray0_ = mclInitializeString(134, _array1_);

static mxChar _array3_[133] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ',
                                'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i',
                                'l', 'e', ':', ' ', 's', 'g', 'l', 't', 'e',
                                's', 't', '1', ' ', 'L', 'i', 'n', 'e', ':',
                                ' ', '1', ' ', 'C', 'o', 'l', 'u', 'm', 'n',
                                ':', ' ', '1', ' ', 'T', 'h', 'e', ' ', 'f',
                                'u', 'n', 'c', 't', 'i', 'o', 'n', ' ', '"',
                                's', 'g', 'l', 't', 'e', 's', 't', '1', '"',
                                ' ', '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', ' ', '(', '1', ')', '.' };
static mwArray _mxarray2_ = mclInitializeString(133, _array3_);
static mwArray _mxarray4_ = mclInitializeDouble(1.0);
static mwArray _mxarray5_ = mclInitializeDouble(50.26548245743669);
static mwArray _mxarray6_ = mclInitializeDouble(2.0);
static mwArray _mxarray7_ = mclInitializeDouble(211.0);
static mwArray _mxarray8_ = mclInitializeDouble(212.0);

static mxChar _array10_[22] = { 'M', 'a', 'x', ' ', '=', ' ', '%', 'd',
                                ',', ' ', 'I', 'n', 'd', 'e', 'x', ' ',
                                '=', ' ', '%', 'd', 0x005c, 'n' };
static mwArray _mxarray9_ = mclInitializeString(22, _array10_);

static mxChar _array12_[6] = { 'R', 'e', 's', 'u', 'l', 't' };
static mwArray _mxarray11_ = mclInitializeString(6, _array12_);

static mxChar _array14_[5] = { 'm', 'o', 'd', 'a', 'l' };
static mwArray _mxarray13_ = mclInitializeString(5, _array14_);

void InitializeModule_sgltest1() {
}

void TerminateModule_sgltest1() {
}

static void Msgltest1(mwArray n);

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

//
// The function "sgltest1" contains the normal interface for the "sgltest1"
// M-function from file "d:\book\soft\ch9\sglcon\sgltest1.m" (lines 1-19). This
// function processes any input arguments and passes them to the implementation
// version of the function, appearing above.
//
void sgltest1(mwArray n) {
    Msgltest1(n);
}

//
// The function "mlxSgltest1" contains the feval interface for the "sgltest1"
// M-function from file "d:\book\soft\ch9\sglcon\sgltest1.m" (lines 1-19). The
// feval function calls the implementation version of sgltest1 through this
// function. This function processes any input arguments and passes them to the
// implementation version of the function, appearing above.
//
void mlxSgltest1(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    MW_BEGIN_MLX();
    {
        mwArray mprhs[1];
        int i;
        if (nlhs > 0) {
            error(_mxarray0_);
        }
        if (nrhs > 1) {
            error(_mxarray2_);
        }
        for (i = 0; i < 1 && i < nrhs; ++i) {
            mprhs[i] = mwArray(prhs[i], 0);
        }
        for (; i < 1; ++i) {
            mprhs[i].MakeDIN();
        }
        Msgltest1(mprhs[0]);
    }
    MW_END_MLX();
}

//
// The function "Msgltest1" is the implementation version of the "sgltest1"
// M-function from file "d:\book\soft\ch9\sglcon\sgltest1.m" (lines 1-19). 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 sgltest1(n)
//
static void Msgltest1(mwArray n) {
    mwLocalFunctionTable save_local_function_table_(&_local_function_table_sgltest1);
    mwArray s(mclGetUninitializedArray());
    mwArray ans(mclGetUninitializedArray());
    mwArray i(mclGetUninitializedArray());
    mwArray m(mclGetUninitializedArray());
    mwArray y(mclGetUninitializedArray());
    mwArray x(mclGetUninitializedArray());
    //
    // 
    // if isstr(n)
    //
    if (tobool(mwVe(isstr(mwVa(n, "n"))))) {
        //
        // n = str2num(n);
        //
        n = str2num(mwVa(n, "n"));
    //
    // end
    //
    }
    //
    // 
    // x = sin([1:n]/n*(16*pi));
    //
    x = sin(colon(_mxarray4_, mwVa(n, "n")) / mwVa(n, "n") * _mxarray5_);
    //
    // y = abs(fft(x));
    //
    y = abs(mwVe(fft(mwVv(x, "x"))));
    //
    // y = y(1:n/2);
    //
    y
      = mclArrayRef(
          mwVsv(y, "y"), colon(_mxarray4_, mwVa(n, "n") / _mxarray6_));
    //
    // [m i] = max(y);
    //
    m = max(&i, mwVv(y, "y"));
    //
    // 
    // subplot(211)
    //
    ans.EqPrintAns(Nsubplot(0, _mxarray7_));
    //
    // plot(x)
    //
    ans.EqPrintAns(Nplot(0, mwVarargin(mwVv(x, "x"))));
    //
    // subplot(212)
    //
    ans.EqPrintAns(Nsubplot(0, _mxarray8_));
    //
    // plot(y)
    //
    ans.EqPrintAns(Nplot(0, mwVarargin(mwVv(y, "y"))));
    //
    // 
    // s = sprintf('Max = %d, Index = %d\n', m, i);
    //
    s = sprintf(_mxarray9_, mwVarargin(mwVv(m, "m"), mwVv(i, "i")));
    //
    // uiwait(msgbox(s, 'Result', 'modal'));
    //
    uiwait(
      mwVe(
        Nmsgbox(
          0,
          mwValueVarargout(),
          mwVarargin(mwVv(s, "s"), _mxarray11_, _mxarray13_))));
    //
    // close
    //
    ans.EqPrintAns(Nclose(0, mwVarargin()));
}

⌨️ 快捷键说明

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