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

📄 myrandplot.c

📁 精通matlab7.0及与其他语言的混合编程
💻 C
字号:
/*
 * MATLAB Compiler: 3.0
 * Date: Tue Nov 15 09:19:57 2005
 * 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" "-M" "-silentsetup" "-d"
 * "C:/MATLAB6p5/work/myrandplottest/src" "-v" "-B"
 * "csglcom:myrandplottest,myrandplottest,1.0" "-B" "sgl" "-m" "-W" "main" "-L"
 * "C" "-t" "-T" "link:exe" "-h" "libmmfile.mlib" "-W" "mainhg"
 * "libmwsglm.mlib" "-t" "-W" "comhg:myrandplottest,myrandplottest,1.0" "-T"
 * "link:lib" "-h" "libmmfile.mlib" "-i" "-g" "-G" "-A" "debugline:on" "-O"
 * "none" "-O" "fold_scalar_mxarrays:off" "-O" "fold_non_scalar_mxarrays:off"
 * "-O" "optimize_integer_for_loops:off" "-O" "array_indexing:off" "-O"
 * "optimize_conditionals:off" "-O" "speculate:off" "-i"
 * "C:/MATLAB6p5/work/getplotcolor.m" "C:/MATLAB6p5/work/myrandplot.m"
 * "C:/MATLAB6p5/work/setplotcolor.m" 
 */
#include "myrandplot.h"
#include "libmatlbm.h"

extern mxArray * randplotcolor;

static double _array0_[3] = { 0.0, 0.0, 1.0 };

void InitializeModule_myrandplot(void) {
}

void TerminateModule_myrandplot(void) {
}

static mxArray * Mmyrandplot(int nargout_, mxArray * n);

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

/*
 * The function "mlfMyrandplot" contains the normal interface for the
 * "myrandplot" M-function from file "c:\matlab6p5\work\myrandplot.m" (lines
 * 1-11). This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
mxArray * mlfMyrandplot(mxArray * n) {
    int nargout = 1;
    mxArray * out = NULL;
    mlfEnterNewContext(0, 1, n);
    out = Mmyrandplot(nargout, n);
    mlfRestorePreviousContext(0, 1, n);
    return mlfReturnValue(out);
}

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

/*
 * The function "Mmyrandplot" is the implementation version of the "myrandplot"
 * M-function from file "c:\matlab6p5\work\myrandplot.m" (lines 1-11). 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 [out]=myrandplot(n)
 */
static mxArray * Mmyrandplot(int nargout_, mxArray * n) {
    mclMlineEnterFunction("c:\\matlab6p5\\work\\myrandplot.m", "myrandplot")
    mexLocalFunctionTable save_local_function_table_
      = mclSetCurrentLocalFunctionTable(&_local_function_table_myrandplot);
    mxArray * out = NULL;
    mxArray * ans = NULL;
    mclCopyArray(&n);
    /*
     * 
     * global randplotcolor;
     * if length(n)>1
     */
    mclMline(4);
    if (mclLengthInt(mclVa(n, "n")) > 1) {
        /*
         * n=n(1);
         */
        mclMline(5);
        mlfAssign(&n, mlfIndexRef(mclVa(n, "n"), "(?)", mlfScalar(1)));
    /*
     * end
     */
    mclMline(6);
    }
    /*
     * out=rand(1, n);
     */
    mclMline(7);
    mlfAssign(&out, mlfNRand(1, mlfScalar(1), mclVa(n, "n"), NULL));
    /*
     * if isempty(randplotcolor)
     */
    mclMline(8);
    if (mlfTobool(mlfIsempty(mclVg(&randplotcolor, "randplotcolor")))) {
        /*
         * randplotcolor=[0 0 1];
         */
        mclMline(9);
        mlfAssign(
          mclPrepareGlobal(&randplotcolor),
          mlfDoubleMatrix(1, 3, _array0_, (double *)NULL));
    /*
     * end
     */
    mclMline(10);
    }
    /*
     * plot(out, 'color', randplotcolor);
     */
    mclAssignAns(
      &ans,
      mlfNPlot(
        0,
        mclVv(out, "out"),
        mxCreateString("color"),
        mclVg(&randplotcolor, "randplotcolor"),
        NULL));
    mclValidateOutput(out, 1, nargout_, "out", "myrandplot");
    mxDestroyArray(ans);
    mxDestroyArray(n);
    mclSetCurrentLocalFunctionTable(save_local_function_table_);
    mclMlineFunctionReturn()
    return out;
    mclMlineExitFunctionReturn();
}

⌨️ 快捷键说明

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