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

📄 subplot.cpp

📁 MATLAB命令行下mcc命令示范3
💻 CPP
📖 第 1 页 / 共 4 页
字号:
    mwArray handle(mclGetUninitializedArray());
    mwArray tol(mclGetUninitializedArray());
    mwArray delay_destroy(mclGetUninitializedArray());
    mwArray create_axis(mclGetUninitializedArray());
    mwArray kill_siblings(mclGetUninitializedArray());
    mwArray narg(mclGetUninitializedArray());
    //
    // %SUBPLOT Create axes in tiled positions.
    // %   H = SUBPLOT(m,n,p), or SUBPLOT(mnp), breaks the Figure window
    // %   into an m-by-n matrix of small axes, selects the p-th axes for 
    // %   for the current plot, and returns the axis handle.  The axes 
    // %   are counted along the top row of the Figure window, then the
    // %   second row, etc.  For example,
    // % 
    // %       SUBPLOT(2,1,1), PLOT(income)
    // %       SUBPLOT(2,1,2), PLOT(outgo)
    // % 
    // %   plots income on the top half of the window and outgo on the
    // %   bottom half.
    // % 
    // %   SUBPLOT(m,n,p), if the axis already exists, makes it current.
    // %   SUBPLOT(m,n,P), where P is a vector, specifies an axes position
    // %   that covers all the subplot positions listed in P.
    // %   SUBPLOT(H), where H is an axis handle, is another way of making
    // %   an axis current for subsequent plotting commands.
    // %
    // %   SUBPLOT('position',[left bottom width height]) creates an
    // %   axis at the specified position in normalized coordinates (in 
    // %   in the range from 0.0 to 1.0).
    // %
    // %   If a SUBPLOT specification causes a new axis to overlap an
    // %   existing axis, the existing axis is deleted.  For example,
    // %   the statement SUBPLOT(1,2,1) deletes all existing axes overlapping
    // %   the left side of the Figure window and creates a new axis on that
    // %   side.
    // %
    // %   SUBPLOT(111) is an exception to the rules above, and is not
    // %   identical in behavior to SUBPLOT(1,1,1).  For reasons of backwards
    // %   compatibility, it is a special case of subplot which does not
    // %   immediately create an axes, but instead sets up the figure so that
    // %   the next graphics command executes CLF RESET in the figure
    // %   (deleting all children of the figure), and creates a new axes in
    // %   the default position.  This syntax does not return a handle, so it
    // %   is an error to specify a return argument.  The delayed CLF RESET
    // %   is accomplished by setting the figure's NextPlot to 'replace'.
    // 
    // %   Copyright 1984-2000 The MathWorks, Inc. 
    // %   $Revision: 5.19 $  $Date: 2000/06/01 02:53:21 $
    // 
    // % we will kill all overlapping axes siblings if we encounter the mnp
    // % or m,n,p specifier (excluding '111').
    // % But if we get the 'position' or H specifier, we won't check for and
    // % delete overlapping siblings:
    // narg = nargin;
    //
    narg = nargin_;
    //
    // kill_siblings = 0;
    //
    kill_siblings = _mxarray4_;
    //
    // create_axis = 1;
    //
    create_axis = _mxarray5_;
    //
    // delay_destroy = 0;
    //
    delay_destroy = _mxarray4_;
    //
    // tol = sqrt(eps);
    //
    tol = sqrt(_mxarray6_);
    //
    // if narg == 0 % make compatible with 3.5, i.e. subplot == subplot(111)
    //
    if (mclEqBool(mwVv(narg, "narg"), _mxarray4_)) {
        //
        // nrows = 111;
        //
        nrows = _mxarray7_;
        //
        // narg = 1;
        //
        narg = _mxarray5_;
    //
    // end
    //
    }
    //
    // 
    // %check for encoded format
    // handle = '';
    //
    handle = _mxarray8_;
    //
    // position = '';
    //
    position = _mxarray8_;
    //
    // if narg == 1
    //
    if (mclEqBool(mwVv(narg, "narg"), _mxarray5_)) {
        //
        // % The argument could be one of 3 things:
        // % 1) a 3-digit number 100 < num < 1000, of the format mnp
        // % 2) a 3-character string containing a number as above
        // % 3) an axis handle
        // code = nrows;
        //
        code = mwVsa(nrows, "nrows");
        //
        // 
        // % turn string into a number:
        // if(isstr(code)) code = str2double(code); end
        //
        if (tobool(mwVe(isstr(mwVv(code, "code"))))) {
            code = str2double(mwVv(code, "code"));
        }
        //
        // 
        // % number with a fractional part can only be an identifier:
        // if(rem(code,1) > 0)
        //
        if (mclGtBool(mwVe(rem(mwVv(code, "code"), _mxarray5_)), _mxarray4_)) {
            //
            // handle = code;
            //
            handle = mwVsv(code, "code");
            //
            // if ~strcmp(get(handle,'type'),'axes')
            //
            if (mclNotBool(
                  mwVe(
                    strcmp(
                      mwVe(
                        Nget(
                          1, mwVarargin(mwVv(handle, "handle"), _mxarray9_))),
                      _mxarray11_)))) {
                //
                // error('Requires valid axes handle for input.')
                //
                error(_mxarray13_);
            //
            // end
            //
            }
            //
            // create_axis = 0;
            //
            create_axis = _mxarray4_;
        //
        // % all other numbers will be converted to mnp format:
        // else
        //
        } else {
            //
            // thisPlot = rem(code, 10);
            //
            thisPlot = rem(mwVv(code, "code"), _mxarray15_);
            //
            // ncols = rem( fix(code-thisPlot)/10,10);
            //
            ncols
              = rem(
                  mwVe(fix(mwVv(code, "code") - mwVa(thisPlot, "thisPlot")))
                  / _mxarray15_,
                  _mxarray15_);
            //
            // nrows = fix(code/100);
            //
            nrows = fix(mwVv(code, "code") / _mxarray16_);
            //
            // if nrows*ncols < thisPlot
            //
            if (mclLtBool(
                  mwVa(nrows, "nrows") * mwVa(ncols, "ncols"),
                  mwVa(thisPlot, "thisPlot"))) {
                //
                // error('Index exceeds number of subplots.');
                //
                error(_mxarray17_);
            //
            // end
            //
            }
            //
            // kill_siblings = 1;
            //
            kill_siblings = _mxarray5_;
            //
            // if(code == 111)
            //
            if (mclEqBool(mwVv(code, "code"), _mxarray7_)) {
                //
                // create_axis   = 0;
                //
                create_axis = _mxarray4_;
                //
                // delay_destroy = 1;
                //
                delay_destroy = _mxarray5_;
            //
            // else
            //
            } else {
                //
                // create_axis   = 1;
                //
                create_axis = _mxarray5_;
                //
                // delay_destroy = 0;
                //
                delay_destroy = _mxarray4_;
            //
            // end
            //
            }
        //
        // end
        //
        }
    //
    // elseif narg == 2
    //
    } else if (mclEqBool(mwVv(narg, "narg"), _mxarray19_)) {
        //
        // % The arguments MUST be the string 'position' and a 4-element vector:
        // if(strcmp(lower(nrows), 'position'))
        //
        if (tobool(
              mwVe(strcmp(mwVe(lower(mwVa(nrows, "nrows"))), _mxarray20_)))) {
            //
            // pos_size = size(ncols);
            //
            pos_size = size(mwValueVarargout(), mwVa(ncols, "ncols"));
            //
            // if(pos_size(1) * pos_size(2) == 4)
            //
            if (mclEqBool(
                  mwVe(mclIntArrayRef(mwVsv(pos_size, "pos_size"), 1))
                  * mwVe(mclIntArrayRef(mwVsv(pos_size, "pos_size"), 2)),
                  _mxarray22_)) {
                //
                // position = ncols;
                //
                position = mwVsa(ncols, "ncols");
            //
            // else
            //
            } else {
                //
                // error(['subplot(''position'',',...
                //
                error(_mxarray23_);
            //
            // ' [left bottom width height]) is what works'])
            // end
            //
            }
        //
        // else
        //
        } else {
            //
            // error('Unknown command option')
            //
            error(_mxarray25_);
        //
        // end
        //
        }
        //
        // kill_siblings = 1; % Kill overlaps here also.
        //
        kill_siblings = _mxarray5_;
    //
    // elseif narg == 3
    //
    } else if (mclEqBool(mwVv(narg, "narg"), _mxarray27_)) {
        //
        // % passed in subplot(m,n,p) -- we should kill overlaps
        // % here too:
        // kill_siblings = 1;
        //
        kill_siblings = _mxarray5_;
    //
    // end
    //
    }
    //
    // 
    // % if we recovered an identifier earlier, use it:
    // if(~isempty(handle))
    //
    if (mclNotBool(mwVe(isempty(mwVv(handle, "handle"))))) {
        //
        // set(get(0,'CurrentFigure'),'CurrentAxes',handle);
        //
        ans.EqAns(
          Nset(
            0,
            mwVarargin(
              mwVe(Nget(1, mwVarargin(_mxarray4_, _mxarray28_))),
              _mxarray30_,
              mwVv(handle, "handle"))));
    //

⌨️ 快捷键说明

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