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

📄 frac_tree_plt.c

📁 本人收集的一些有关matlab的代码程序设计 也不知道改选什么分类
💻 C
字号:
/*
 * MATLAB Compiler: 2.0
 * Date: Tue Apr 18 10:43:29 2000
 * Arguments: "-x" "frac_tree_plt.m" 
 */
#include "frac_tree_plt.h"

/*
 * The function "Mfrac_tree_plt" is the implementation version of the
 * "frac_tree_plt" M-function from file
 * "C:\Xue.Dy\BOOKS\MATLAB\mat5progs\mat5files\frac_tree_plt.m" (lines 1-15).
 * 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 h=frac_tree_plt(x0,y0,v,N)
 */
static mxArray * Mfrac_tree_plt(int nargout_,
                                mxArray * x0,
                                mxArray * y0,
                                mxArray * v,
                                mxArray * N) {
    mxArray * h = mclGetUninitializedArray();
    mxArray * i = mclGetUninitializedArray();
    mclForLoopIterator iterator_0;
    mxArray * vv = mclGetUninitializedArray();
    mxArray * x = mclGetUninitializedArray();
    mxArray * y = mclGetUninitializedArray();
    mclValidateInputs("frac_tree_plt", 4, &x0, &y0, &v, &N);
    /*
     * x=[x0; zeros(N-1,1)]; y=[y0; zeros(N-1,1)];
     */
    mlfAssign(
      &x,
      mlfVertcat(
        mlfHorzcat(x0, NULL),
        mlfHorzcat(
          mlfZeros(mlfMinus(N, mlfScalar(1.0)), mlfScalar(1.0), NULL), NULL),
        NULL));
    mlfAssign(
      &y,
      mlfVertcat(
        mlfHorzcat(y0, NULL),
        mlfHorzcat(
          mlfZeros(mlfMinus(N, mlfScalar(1.0)), mlfScalar(1.0), NULL), NULL),
        NULL));
    /*
     * for i=2:N
     */
    for (mclForStart(&iterator_0, mlfScalar(2.0), N, NULL);
         mclForNext(&iterator_0, &i);
         ) {
        /*
         * vv=v(i);
         */
        mlfAssign(&vv, mlfIndexRef(v, "(?)", i));
        /*
         * if vv<0.05, y(i)=0.5*y(i-1);   
         */
        if (mlfTobool(mlfLt(vv, mlfScalar(0.05)))) {
            mlfIndexAssign(
              &y,
              "(?)",
              i,
              mlfMtimes(
                mlfScalar(0.5),
                mlfIndexRef(y, "(?)", mlfMinus(i, mlfScalar(1.0)))));
        /*
         * elseif vv<0.45, 
         */
        } else if (mlfTobool(mlfLt(vv, mlfScalar(0.45)))) {
            /*
             * x(i)=0.42*(x(i-1)-y(i-1)); y(i)=0.2+0.42*(x(i-1)+y(i-1));
             */
            mlfIndexAssign(
              &x,
              "(?)",
              i,
              mlfMtimes(
                mlfScalar(0.42),
                mlfMinus(
                  mlfIndexRef(x, "(?)", mlfMinus(i, mlfScalar(1.0))),
                  mlfIndexRef(y, "(?)", mlfMinus(i, mlfScalar(1.0))))));
            mlfIndexAssign(
              &y,
              "(?)",
              i,
              mlfPlus(
                mlfScalar(0.2),
                mlfMtimes(
                  mlfScalar(0.42),
                  mlfPlus(
                    mlfIndexRef(x, "(?)", mlfMinus(i, mlfScalar(1.0))),
                    mlfIndexRef(y, "(?)", mlfMinus(i, mlfScalar(1.0)))))));
        /*
         * elseif vv<0.85, 
         */
        } else if (mlfTobool(mlfLt(vv, mlfScalar(0.85)))) {
            /*
             * x(i)=0.42*(x(i-1)+y(i-1)); y(i)=0.2-0.42*(x(i-1)-y(i-1));   
             */
            mlfIndexAssign(
              &x,
              "(?)",
              i,
              mlfMtimes(
                mlfScalar(0.42),
                mlfPlus(
                  mlfIndexRef(x, "(?)", mlfMinus(i, mlfScalar(1.0))),
                  mlfIndexRef(y, "(?)", mlfMinus(i, mlfScalar(1.0))))));
            mlfIndexAssign(
              &y,
              "(?)",
              i,
              mlfMinus(
                mlfScalar(0.2),
                mlfMtimes(
                  mlfScalar(0.42),
                  mlfMinus(
                    mlfIndexRef(x, "(?)", mlfMinus(i, mlfScalar(1.0))),
                    mlfIndexRef(y, "(?)", mlfMinus(i, mlfScalar(1.0)))))));
        /*
         * else, 
         */
        } else {
            /*
             * x(i)=0.1*x(i-1); y(i)=0.1*y(i-1)+0.2;
             */
            mlfIndexAssign(
              &x,
              "(?)",
              i,
              mlfMtimes(
                mlfScalar(0.1),
                mlfIndexRef(x, "(?)", mlfMinus(i, mlfScalar(1.0)))));
            mlfIndexAssign(
              &y,
              "(?)",
              i,
              mlfPlus(
                mlfMtimes(
                  mlfScalar(0.1),
                  mlfIndexRef(y, "(?)", mlfMinus(i, mlfScalar(1.0)))),
                mlfScalar(0.2)));
        /*
         * end
         */
        }
        /*
         * h=plot(x,y,'.');
         */
        mlfAssign(&h, mlfPlot(x, y, mxCreateString("."), NULL));
    /*
     * end
     */
    }
    mclValidateOutputs("frac_tree_plt", 1, nargout_, &h);
    mxDestroyArray(i);
    mxDestroyArray(vv);
    mxDestroyArray(x);
    mxDestroyArray(y);
    return h;
}

/*
 * The function "mlfFrac_tree_plt" contains the normal interface for the
 * "frac_tree_plt" M-function from file
 * "C:\Xue.Dy\BOOKS\MATLAB\mat5progs\mat5files\frac_tree_plt.m" (lines 1-15).
 * This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
mxArray * mlfFrac_tree_plt(mxArray * x0,
                           mxArray * y0,
                           mxArray * v,
                           mxArray * N) {
    int nargout = 1;
    mxArray * h = mclGetUninitializedArray();
    mlfEnterNewContext(0, 4, x0, y0, v, N);
    h = Mfrac_tree_plt(nargout, x0, y0, v, N);
    mlfRestorePreviousContext(0, 4, x0, y0, v, N);
    return mlfReturnValue(h);
}

/*
 * The function "mlxFrac_tree_plt" contains the feval interface for the
 * "frac_tree_plt" M-function from file
 * "C:\Xue.Dy\BOOKS\MATLAB\mat5progs\mat5files\frac_tree_plt.m" (lines 1-15).
 * The feval function calls the implementation version of frac_tree_plt through
 * this function. This function processes any input arguments and passes them
 * to the implementation version of the function, appearing above.
 */
void mlxFrac_tree_plt(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    mxArray * mprhs[4];
    mxArray * mplhs[1];
    int i;
    if (nlhs > 1) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: frac_tree_plt Line: 1 Column"
            ": 0 The function \"frac_tree_plt\" was called with"
            " more than the declared number of outputs (1)"));
    }
    if (nrhs > 4) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: frac_tree_plt Line: 1 Colum"
            "n: 0 The function \"frac_tree_plt\" was called wi"
            "th more than the declared number of inputs (4)"));
    }
    for (i = 0; i < 1; ++i) {
        mplhs[i] = NULL;
    }
    for (i = 0; i < 4 && i < nrhs; ++i) {
        mprhs[i] = prhs[i];
    }
    for (; i < 4; ++i) {
        mprhs[i] = NULL;
    }
    mlfEnterNewContext(0, 4, mprhs[0], mprhs[1], mprhs[2], mprhs[3]);
    mplhs[0] = Mfrac_tree_plt(nlhs, mprhs[0], mprhs[1], mprhs[2], mprhs[3]);
    mlfRestorePreviousContext(0, 4, mprhs[0], mprhs[1], mprhs[2], mprhs[3]);
    plhs[0] = mplhs[0];
}

⌨️ 快捷键说明

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