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

📄 subplot.c

📁 ASUFIT-Matlab-全局拟合程序
💻 C
📖 第 1 页 / 共 3 页
字号:
                /*
                 * set(sibs(i),'Units','normalized')
                 */
                mclPrintAns(
                  &ans,
                  mlfNSet(
                    0,
                    mlfIndexRef(sibs, "(?)", i),
                    mxCreateString("Units"),
                    mxCreateString("normalized"),
                    NULL));
                /*
                 * sibpos = get(sibs(i),'Position');
                 */
                mlfAssign(
                  &sibpos,
                  mlfGet(
                    mlfIndexRef(sibs, "(?)", i),
                    mxCreateString("Position"),
                    NULL));
                /*
                 * set(sibs(i),'Units',units);
                 */
                mclAssignAns(
                  &ans,
                  mlfNSet(
                    0,
                    mlfIndexRef(sibs, "(?)", i),
                    mxCreateString("Units"),
                    units,
                    NULL));
                /*
                 * intersect = 1;
                 */
                mlfAssign(&intersect, mlfScalar(1.0));
                /*
                 * if(     (position(1) >= sibpos(1) + sibpos(3)-tol) | ...
                 */
                {
                    mxArray * a_ = mclInitialize(
                                     mlfGe(
                                       mlfIndexRef(
                                         position, "(?)", mlfScalar(1.0)),
                                       mlfMinus(
                                         mlfPlus(
                                           mlfIndexRef(
                                             sibpos, "(?)", mlfScalar(1.0)),
                                           mlfIndexRef(
                                             sibpos, "(?)", mlfScalar(3.0))),
                                         tol)));
                    if (mlfTobool(a_)) {
                        /*
                         * (sibpos(1) >= position(1) + position(3)-tol) | ...
                         */
                        mlfAssign(&a_, mlfScalar(1));
                    } else {
                        mlfAssign(
                          &a_,
                          mlfOr(
                            a_,
                            mlfGe(
                              mlfIndexRef(sibpos, "(?)", mlfScalar(1.0)),
                              mlfMinus(
                                mlfPlus(
                                  mlfIndexRef(position, "(?)", mlfScalar(1.0)),
                                  mlfIndexRef(position, "(?)", mlfScalar(3.0))),
                                tol))));
                    }
                    if (mlfTobool(a_)) {
                        mlfAssign(&a_, mlfScalar(1));
                    } else {
                        mlfAssign(
                          &a_,
                          mlfOr(
                            a_,
                            mlfGe(
                              mlfIndexRef(position, "(?)", mlfScalar(2.0)),
                              mlfMinus(
                                mlfPlus(
                                  mlfIndexRef(sibpos, "(?)", mlfScalar(2.0)),
                                  mlfIndexRef(sibpos, "(?)", mlfScalar(4.0))),
                                tol))));
                    }
                    if (mlfTobool(a_)
                        || mlfTobool(
                             mlfOr(
                               a_,
                               mlfGe(
                                 mlfIndexRef(sibpos, "(?)", mlfScalar(2.0)),
                                 mlfMinus(
                                   mlfPlus(
                                     mlfIndexRef(
                                       position, "(?)", mlfScalar(2.0)),
                                     mlfIndexRef(
                                       position, "(?)", mlfScalar(4.0))),
                                   tol))))) {
                        mxDestroyArray(a_);
                        /*
                         * (position(2) >= sibpos(2) + sibpos(4)-tol) | ...
                         * (sibpos(2) >= position(2) + position(4)-tol))
                         * intersect = 0;
                         */
                        mlfAssign(&intersect, mlfScalar(0.0));
                    } else {
                        mxDestroyArray(a_);
                    }
                /*
                 * end
                 */
                }
                /*
                 * if intersect
                 */
                if (mlfTobool(intersect)) {
                    /*
                     * if got_one | any(abs(sibpos - position) > tol)
                     */
                    if (mlfTobool(got_one)
                        || mlfTobool(
                             mlfOr(
                               got_one,
                               mlfAny(
                                 mlfGt(
                                   mlfAbs(mlfMinus(sibpos, position)), tol),
                                 NULL)))) {
                        /*
                         * delete(sibs(i));
                         */
                        mlfDelete(mlfIndexRef(sibs, "(?)", i), NULL);
                    /*
                     * else
                     */
                    } else {
                        /*
                         * got_one = 1;
                         */
                        mlfAssign(&got_one, mlfScalar(1.0));
                        /*
                         * set(gcf,'CurrentAxes',sibs(i));
                         */
                        mclAssignAns(
                          &ans,
                          mlfNSet(
                            0,
                            mlfGcf(),
                            mxCreateString("CurrentAxes"),
                            mlfIndexRef(sibs, "(?)", i),
                            NULL));
                        /*
                         * if strcmp(nextstate,'new')
                         */
                        if (mlfTobool(
                              mlfStrcmp(nextstate, mxCreateString("new")))) {
                            /*
                             * create_axis = 1;
                             */
                            mlfAssign(&create_axis, mlfScalar(1.0));
                        /*
                         * else
                         */
                        } else {
                            /*
                             * create_axis = 0;
                             */
                            mlfAssign(&create_axis, mlfScalar(0.0));
                        /*
                         * end
                         */
                        }
                    /*
                     * end
                     */
                    }
                /*
                 * end
                 */
                }
            } else {
                mxDestroyArray(a_);
            }
        /*
         * end
         * end
         */
        }
        /*
         * set(gcf,'NextPlot',nextstate);
         */
        mclAssignAns(
          &ans,
          mlfNSet(0, mlfGcf(), mxCreateString("NextPlot"), nextstate, NULL));
    /*
     * end
     */
    }
    /*
     * 
     * % create the axis:
     * if create_axis
     */
    if (mlfTobool(create_axis)) {
        /*
         * if strcmp(nextstate,'new'), figure, end
         */
        if (mlfTobool(mlfStrcmp(nextstate, mxCreateString("new")))) {
            mclPrintAns(&ans, mlfNFigure(0, NULL));
        }
        /*
         * ax = axes('units','normal','Position', position);
         */
        mlfAssign(
          &ax,
          mlfNAxes(
            1,
            mxCreateString("units"),
            mxCreateString("normal"),
            mxCreateString("Position"),
            position,
            NULL));
        /*
         * set(ax,'units',get(gcf,'defaultaxesunits'))
         */
        mclPrintAns(
          &ans,
          mlfNSet(
            0,
            ax,
            mxCreateString("units"),
            mlfGet(mlfGcf(), mxCreateString("defaultaxesunits"), NULL),
            NULL));
    /*
     * else 
     */
    } else {
        /*
         * ax = gca; 
         */
        mlfAssign(&ax, mlfGca(NULL));
    /*
     * end
     */
    }
    /*
     * 
     * 
     * % return identifier, if requested:
     * if(nargout > 0)
     */
    if (mlfTobool(mlfGt(nargout, mlfScalar(0.0)))) {
        /*
         * theAxis = ax;
         */
        mlfAssign(&theAxis, ax);
    /*
     * end
     */
    }
    return_:
    mclValidateOutputs("subplot", 1, nargout_, &theAxis);
    mxDestroyArray(PERC_OFFSET_B);
    mxDestroyArray(PERC_OFFSET_L);
    mxDestroyArray(PERC_OFFSET_R);
    mxDestroyArray(PERC_OFFSET_T);
    mxDestroyArray(ans);
    mxDestroyArray(ax);
    mxDestroyArray(code);
    mxDestroyArray(col);
    mxDestroyArray(col_offset);
    mxDestroyArray(create_axis);
    mxDestroyArray(def_pos);
    mxDestroyArray(delay_destroy);
    mxDestroyArray(got_one);
    mxDestroyArray(handle);
    mxDestroyArray(height);
    mxDestroyArray(i);
    mxDestroyArray(intersect);
    mxDestroyArray(kill_siblings);
    mxDestroyArray(narg);
    mxDestroyArray(nargin_);
    mxDestroyArray(nargout);
    mxDestroyArray(ncols);
    mxDestroyArray(nextstate);
    mxDestroyArray(nrows);
    mxDestroyArray(pos_size);
    mxDestroyArray(position);
    mxDestroyArray(row);
    mxDestroyArray(row_offset);
    mxDestroyArray(sibpos);
    mxDestroyArray(sibs);
    mxDestroyArray(thisPlot);
    mxDestroyArray(tmp);
    mxDestroyArray(tol);
    mxDestroyArray(totalheight);
    mxDestroyArray(totalwidth);
    mxDestroyArray(units);
    mxDestroyArray(width);
    return theAxis;
}

/*
 * The function "mlfNSubplot" contains the nargout interface for the "subplot"
 * M-function from file "C:\MATLABR11\toolbox\matlab\graph2d\subplot.m" (lines
 * 1-232). This interface is only produced if the M-function uses the special
 * variable "nargout". The nargout interface allows the number of requested
 * outputs to be specified via the nargout argument, as opposed to the normal
 * interface which dynamically calculates the number of outputs based on the
 * number of non-NULL inputs it receives. This function processes any input
 * arguments and passes them to the implementation version of the function,
 * appearing above.
 */
mxArray * mlfNSubplot(int nargout,
                      mxArray * nrows,
                      mxArray * ncols,
                      mxArray * thisPlot) {
    mxArray * theAxis = mclGetUninitializedArray();
    mlfEnterNewContext(0, 3, nrows, ncols, thisPlot);
    theAxis = Msubplot(nargout, nrows, ncols, thisPlot);
    mlfRestorePreviousContext(0, 3, nrows, ncols, thisPlot);
    return mlfReturnValue(theAxis);
}

/*
 * The function "mlfSubplot" contains the normal interface for the "subplot"
 * M-function from file "C:\MATLABR11\toolbox\matlab\graph2d\subplot.m" (lines
 * 1-232). This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
mxArray * mlfSubplot(mxArray * nrows, mxArray * ncols, mxArray * thisPlot) {
    int nargout = 1;
    mxArray * theAxis = mclGetUninitializedArray();
    mlfEnterNewContext(0, 3, nrows, ncols, thisPlot);
    theAxis = Msubplot(nargout, nrows, ncols, thisPlot);
    mlfRestorePreviousContext(0, 3, nrows, ncols, thisPlot);
    return mlfReturnValue(theAxis);
}

/*
 * The function "mlfVSubplot" contains the void interface for the "subplot"
 * M-function from file "C:\MATLABR11\toolbox\matlab\graph2d\subplot.m" (lines
 * 1-232). The void interface is only produced if the M-function uses the
 * special variable "nargout", and has at least one output. The void interface
 * function specifies zero output arguments to the implementation version of
 * the function, and in the event that the implementation version still returns
 * an output (which, in MATLAB, would be assigned to the "ans" variable), it
 * deallocates the output. This function processes any input arguments and
 * passes them to the implementation version of the function, appearing above.
 */
void mlfVSubplot(mxArray * nrows, mxArray * ncols, mxArray * thisPlot) {
    mxArray * theAxis = mclUnassigned();
    mlfEnterNewContext(0, 3, nrows, ncols, thisPlot);
    theAxis = Msubplot(0, nrows, ncols, thisPlot);
    mlfRestorePreviousContext(0, 3, nrows, ncols, thisPlot);
    mxDestroyArray(theAxis);
}

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

⌨️ 快捷键说明

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