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

📄 subplot.c

📁 ASUFIT-Matlab-全局拟合程序
💻 C
📖 第 1 页 / 共 3 页
字号:
             * % This is the percent offset from the subplot grid of the plotbox.
             * PERC_OFFSET_L = 2*0.09;
             */
            mlfAssign(
              &PERC_OFFSET_L, mlfMtimes(mlfScalar(2.0), mlfScalar(0.09)));
            /*
             * PERC_OFFSET_R = 2*0.045;
             */
            mlfAssign(
              &PERC_OFFSET_R, mlfMtimes(mlfScalar(2.0), mlfScalar(0.045)));
            /*
             * PERC_OFFSET_B = PERC_OFFSET_L;
             */
            mlfAssign(&PERC_OFFSET_B, PERC_OFFSET_L);
            /*
             * PERC_OFFSET_T = PERC_OFFSET_R;
             */
            mlfAssign(&PERC_OFFSET_T, PERC_OFFSET_R);
            /*
             * if nrows > 2
             */
            if (mlfTobool(mlfGt(nrows, mlfScalar(2.0)))) {
                /*
                 * PERC_OFFSET_T = 0.9*PERC_OFFSET_T;
                 */
                mlfAssign(
                  &PERC_OFFSET_T, mlfMtimes(mlfScalar(0.9), PERC_OFFSET_T));
                /*
                 * PERC_OFFSET_B = 0.9*PERC_OFFSET_B;
                 */
                mlfAssign(
                  &PERC_OFFSET_B, mlfMtimes(mlfScalar(0.9), PERC_OFFSET_B));
            /*
             * end
             */
            }
            /*
             * if ncols > 2
             */
            if (mlfTobool(mlfGt(ncols, mlfScalar(2.0)))) {
                /*
                 * PERC_OFFSET_L = 0.9*PERC_OFFSET_L;
                 */
                mlfAssign(
                  &PERC_OFFSET_L, mlfMtimes(mlfScalar(0.9), PERC_OFFSET_L));
                /*
                 * PERC_OFFSET_R = 0.9*PERC_OFFSET_R;
                 */
                mlfAssign(
                  &PERC_OFFSET_R, mlfMtimes(mlfScalar(0.9), PERC_OFFSET_R));
            /*
             * end
             */
            }
            /*
             * 
             * row = (nrows-1) -fix((thisPlot-1)/ncols);
             */
            mlfAssign(
              &row,
              mlfMinus(
                mlfMinus(nrows, mlfScalar(1.0)),
                mlfFix(
                  mlfMrdivide(mlfMinus(thisPlot, mlfScalar(1.0)), ncols))));
            /*
             * col = rem (thisPlot-1, ncols);
             */
            mlfAssign(&col, mlfRem(mlfMinus(thisPlot, mlfScalar(1.0)), ncols));
            /*
             * 
             * % For this to work the default axes position must be in normalized coordinates
             * if ~strcmp(get(gcf,'defaultaxesunits'),'normalized')
             */
            if (mlfTobool(
                  mlfNot(
                    mlfStrcmp(
                      mlfGet(
                        mlfGcf(), mxCreateString("defaultaxesunits"), NULL),
                      mxCreateString("normalized"))))) {
                /*
                 * warning('DefaultAxesUnits not normalized.')
                 */
                mclPrintAns(
                  &ans,
                  mlfWarning(
                    NULL, mxCreateString("DefaultAxesUnits not normalized.")));
                /*
                 * tmp = axes;
                 */
                mlfAssign(&tmp, mlfNAxes(1, NULL));
                /*
                 * set(axes,'units','normalized')
                 */
                mclPrintAns(
                  &ans,
                  mlfNSet(
                    0,
                    mlfNAxes(1, NULL),
                    mxCreateString("units"),
                    mxCreateString("normalized"),
                    NULL));
                /*
                 * def_pos = get(tmp,'position');
                 */
                mlfAssign(
                  &def_pos, mlfGet(tmp, mxCreateString("position"), NULL));
                /*
                 * delete(tmp)
                 */
                mlfDelete(tmp, NULL);
            /*
             * else
             */
            } else {
                /*
                 * def_pos = get(gcf,'DefaultAxesPosition');
                 */
                mlfAssign(
                  &def_pos,
                  mlfGet(
                    mlfGcf(), mxCreateString("DefaultAxesPosition"), NULL));
            /*
             * end
             */
            }
            /*
             * col_offset = def_pos(3)*(PERC_OFFSET_L+PERC_OFFSET_R)/ ...
             */
            mlfAssign(
              &col_offset,
              mlfMrdivide(
                mlfMtimes(
                  mlfIndexRef(def_pos, "(?)", mlfScalar(3.0)),
                  mlfPlus(PERC_OFFSET_L, PERC_OFFSET_R)),
                mlfMinus(mlfMinus(ncols, PERC_OFFSET_L), PERC_OFFSET_R)));
            /*
             * (ncols-PERC_OFFSET_L-PERC_OFFSET_R);
             * row_offset = def_pos(4)*(PERC_OFFSET_B+PERC_OFFSET_T)/ ...
             */
            mlfAssign(
              &row_offset,
              mlfMrdivide(
                mlfMtimes(
                  mlfIndexRef(def_pos, "(?)", mlfScalar(4.0)),
                  mlfPlus(PERC_OFFSET_B, PERC_OFFSET_T)),
                mlfMinus(mlfMinus(nrows, PERC_OFFSET_B), PERC_OFFSET_T)));
            /*
             * (nrows-PERC_OFFSET_B-PERC_OFFSET_T);
             * totalwidth = def_pos(3) + col_offset;
             */
            mlfAssign(
              &totalwidth,
              mlfPlus(mlfIndexRef(def_pos, "(?)", mlfScalar(3.0)), col_offset));
            /*
             * totalheight = def_pos(4) + row_offset;
             */
            mlfAssign(
              &totalheight,
              mlfPlus(mlfIndexRef(def_pos, "(?)", mlfScalar(4.0)), row_offset));
            /*
             * width = totalwidth/ncols*(max(col)-min(col)+1)-col_offset;
             */
            mlfAssign(
              &width,
              mlfMinus(
                mlfMtimes(
                  mlfMrdivide(totalwidth, ncols),
                  mlfPlus(
                    mlfMinus(
                      mlfMax(NULL, col, NULL, NULL),
                      mlfMin(NULL, col, NULL, NULL)),
                    mlfScalar(1.0))),
                col_offset));
            /*
             * height = totalheight/nrows*(max(row)-min(row)+1)-row_offset;
             */
            mlfAssign(
              &height,
              mlfMinus(
                mlfMtimes(
                  mlfMrdivide(totalheight, nrows),
                  mlfPlus(
                    mlfMinus(
                      mlfMax(NULL, row, NULL, NULL),
                      mlfMin(NULL, row, NULL, NULL)),
                    mlfScalar(1.0))),
                row_offset));
            /*
             * position = [def_pos(1)+min(col)*totalwidth/ncols ...
             */
            mlfAssign(
              &position,
              mlfHorzcat(
                mlfPlus(
                  mlfIndexRef(def_pos, "(?)", mlfScalar(1.0)),
                  mlfMrdivide(
                    mlfMtimes(mlfMin(NULL, col, NULL, NULL), totalwidth),
                    ncols)),
                mlfPlus(
                  mlfIndexRef(def_pos, "(?)", mlfScalar(2.0)),
                  mlfMrdivide(
                    mlfMtimes(mlfMin(NULL, row, NULL, NULL), totalheight),
                    nrows)),
                width,
                height,
                NULL));
            /*
             * def_pos(2)+min(row)*totalheight/nrows ...
             * width height];
             * if width <= 0.5*totalwidth/ncols
             */
            if (mlfTobool(
                  mlfLe(
                    width,
                    mlfMrdivide(
                      mlfMtimes(mlfScalar(0.5), totalwidth), ncols)))) {
                /*
                 * position(1) = def_pos(1)+min(col)*(def_pos(3)/ncols);
                 */
                mlfIndexAssign(
                  &position,
                  "(?)",
                  mlfScalar(1.0),
                  mlfPlus(
                    mlfIndexRef(def_pos, "(?)", mlfScalar(1.0)),
                    mlfMtimes(
                      mlfMin(NULL, col, NULL, NULL),
                      mlfMrdivide(
                        mlfIndexRef(def_pos, "(?)", mlfScalar(3.0)), ncols))));
                /*
                 * position(3) = 0.7*(def_pos(3)/ncols)*(max(col)-min(col)+1);
                 */
                mlfIndexAssign(
                  &position,
                  "(?)",
                  mlfScalar(3.0),
                  mlfMtimes(
                    mlfMtimes(
                      mlfScalar(0.7),
                      mlfMrdivide(
                        mlfIndexRef(def_pos, "(?)", mlfScalar(3.0)), ncols)),
                    mlfPlus(
                      mlfMinus(
                        mlfMax(NULL, col, NULL, NULL),
                        mlfMin(NULL, col, NULL, NULL)),
                      mlfScalar(1.0))));
            /*
             * end
             */
            }
            /*
             * if height <= 0.5*totalheight/nrows
             */
            if (mlfTobool(
                  mlfLe(
                    height,
                    mlfMrdivide(
                      mlfMtimes(mlfScalar(0.5), totalheight), nrows)))) {
                /*
                 * position(2) = def_pos(2)+min(row)*(def_pos(4)/nrows);
                 */
                mlfIndexAssign(
                  &position,
                  "(?)",
                  mlfScalar(2.0),
                  mlfPlus(
                    mlfIndexRef(def_pos, "(?)", mlfScalar(2.0)),
                    mlfMtimes(
                      mlfMin(NULL, row, NULL, NULL),
                      mlfMrdivide(
                        mlfIndexRef(def_pos, "(?)", mlfScalar(4.0)), nrows))));
                /*
                 * position(4) = 0.7*(def_pos(4)/nrows)*(max(row)-min(row)+1);
                 */
                mlfIndexAssign(
                  &position,
                  "(?)",
                  mlfScalar(4.0),
                  mlfMtimes(
                    mlfMtimes(
                      mlfScalar(0.7),
                      mlfMrdivide(
                        mlfIndexRef(def_pos, "(?)", mlfScalar(4.0)), nrows)),
                    mlfPlus(
                      mlfMinus(
                        mlfMax(NULL, row, NULL, NULL),
                        mlfMin(NULL, row, NULL, NULL)),
                      mlfScalar(1.0))));
            /*
             * end
             */
            }
        /*
         * end
         */
        }
    /*
     * end
     */
    }
    /*
     * 
     * % kill overlapping siblings if mnp specifier was used:
     * nextstate = get(gcf,'nextplot');
     */
    mlfAssign(&nextstate, mlfGet(mlfGcf(), mxCreateString("nextplot"), NULL));
    /*
     * if strncmp(nextstate,'replace',7), nextstate = 'add'; end
     */
    if (mlfTobool(
          mlfStrncmp(nextstate, mxCreateString("replace"), mlfScalar(7.0)))) {
        mlfAssign(&nextstate, mxCreateString("add"));
    }
    /*
     * if(kill_siblings)
     */
    if (mlfTobool(kill_siblings)) {
        /*
         * if delay_destroy
         */
        if (mlfTobool(delay_destroy)) {
            /*
             * if nargout
             */
            if (mlfTobool(nargout)) {
                /*
                 * error('Function called with too many output arguments')
                 */
                mlfError(
                  mxCreateString(
                    "Function called with too many output arguments"));
            /*
             * else
             */
            } else {
                /*
                 * set(gcf,'NextPlot','replace'); return,
                 */
                mclAssignAns(
                  &ans,
                  mlfNSet(
                    0,
                    mlfGcf(),
                    mxCreateString("NextPlot"),
                    mxCreateString("replace"),
                    NULL));
                goto return_;
            /*
             * end
             */
            }
        /*
         * end
         */
        }
        /*
         * sibs = datachildren(gcf);
         */
        mlfAssign(&sibs, mlfDatachildren(mlfGcf()));
        /*
         * got_one = 0;
         */
        mlfAssign(&got_one, mlfScalar(0.0));
        /*
         * for i = 1:length(sibs)
         */
        for (mclForStart(&iterator_0, mlfScalar(1.0), mlfLength(sibs), NULL);
             mclForNext(&iterator_0, &i);
             ) {
            /*
             * % Be aware that handles in this list might be destroyed before
             * % we get to them, because of other objects' DeleteFcn callbacks...
             * if(ishandle(sibs(i)) & strcmp(get(sibs(i),'Type'),'axes'))
             */
            mxArray * a_ = mclInitialize(
                             mlfIshandle(mlfIndexRef(sibs, "(?)", i)));
            if (mlfTobool(a_)
                && mlfTobool(
                     mlfAnd(
                       a_,
                       mlfStrcmp(
                         mlfGet(
                           mlfIndexRef(sibs, "(?)", i),
                           mxCreateString("Type"),
                           NULL),
                         mxCreateString("axes"))))) {
                mxDestroyArray(a_);
                /*
                 * units = get(sibs(i),'Units');
                 */
                mlfAssign(
                  &units,
                  mlfGet(
                    mlfIndexRef(sibs, "(?)", i),
                    mxCreateString("Units"),
                    NULL));

⌨️ 快捷键说明

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