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

📄 subplot.c

📁 ASUFIT-Matlab-全局拟合程序
💻 C
📖 第 1 页 / 共 3 页
字号:
/*
 * MATLAB Compiler: 2.0.1
 * Date: Tue May 08 21:28:23 2001
 * Arguments: "-B" "sgl" "-m" "-W" "mainhg" "-L" "C" "asufit.m" "absfun.m"
 * "absfunfree.m" "absfunshift.m" "absfunwidth.m" "dispfit.m" "dispfitdisp.m"
 * "dispfitfree.m" "dispfitwidth.m" "seqmodfree.m" "spcfun.m" "spcfun1.m"
 * "atamult.m" "aprecon.m" 
 */
#include "subplot.h"

/*
 * The function "Msubplot" is the implementation version of the "subplot"
 * M-function from file "C:\MATLABR11\toolbox\matlab\graph2d\subplot.m" (lines
 * 1-232). 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 theAxis = subplot(nrows, ncols, thisPlot)
 */
static mxArray * Msubplot(int nargout_,
                          mxArray * nrows,
                          mxArray * ncols,
                          mxArray * thisPlot) {
    mxArray * theAxis = mclGetUninitializedArray();
    mxArray * PERC_OFFSET_B = mclGetUninitializedArray();
    mxArray * PERC_OFFSET_L = mclGetUninitializedArray();
    mxArray * PERC_OFFSET_R = mclGetUninitializedArray();
    mxArray * PERC_OFFSET_T = mclGetUninitializedArray();
    mxArray * ans = mclInitializeAns();
    mxArray * ax = mclGetUninitializedArray();
    mxArray * code = mclGetUninitializedArray();
    mxArray * col = mclGetUninitializedArray();
    mxArray * col_offset = mclGetUninitializedArray();
    mxArray * create_axis = mclGetUninitializedArray();
    mxArray * def_pos = mclGetUninitializedArray();
    mxArray * delay_destroy = mclGetUninitializedArray();
    mxArray * got_one = mclGetUninitializedArray();
    mxArray * handle = mclGetUninitializedArray();
    mxArray * height = mclGetUninitializedArray();
    mxArray * i = mclGetUninitializedArray();
    mxArray * intersect = mclGetUninitializedArray();
    mclForLoopIterator iterator_0;
    mxArray * kill_siblings = mclGetUninitializedArray();
    mxArray * narg = mclGetUninitializedArray();
    mxArray * nargin_ = mclGetUninitializedArray();
    mxArray * nargout = mclInitialize(mlfScalar(nargout_));
    mxArray * nextstate = mclGetUninitializedArray();
    mxArray * pos_size = mclGetUninitializedArray();
    mxArray * position = mclGetUninitializedArray();
    mxArray * row = mclGetUninitializedArray();
    mxArray * row_offset = mclGetUninitializedArray();
    mxArray * sibpos = mclGetUninitializedArray();
    mxArray * sibs = mclGetUninitializedArray();
    mxArray * tmp = mclGetUninitializedArray();
    mxArray * tol = mclGetUninitializedArray();
    mxArray * totalheight = mclGetUninitializedArray();
    mxArray * totalwidth = mclGetUninitializedArray();
    mxArray * units = mclGetUninitializedArray();
    mxArray * width = mclGetUninitializedArray();
    mlfAssign(&nargin_, mlfNargin(0, nrows, ncols, thisPlot, NULL));
    mclValidateInputs("subplot", 3, &nrows, &ncols, &thisPlot);
    mclCopyArray(&nrows);
    mclCopyArray(&ncols);
    mclCopyArray(&thisPlot);
    /*
     * %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(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 (c) 1984-98 by The MathWorks, Inc.
     * %   $Revision: 5.14 $  $Date: 1998/10/20 19:26:58 $
     * 
     * % 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;
     */
    mlfAssign(&narg, nargin_);
    /*
     * kill_siblings = 0;
     */
    mlfAssign(&kill_siblings, mlfScalar(0.0));
    /*
     * create_axis = 1;
     */
    mlfAssign(&create_axis, mlfScalar(1.0));
    /*
     * delay_destroy = 0;
     */
    mlfAssign(&delay_destroy, mlfScalar(0.0));
    /*
     * tol = sqrt(eps);
     */
    mlfAssign(&tol, mlfSqrt(mlfEps()));
    /*
     * if narg == 0 % make compatible with 3.5, i.e. subplot == subplot(111)
     */
    if (mlfTobool(mlfEq(narg, mlfScalar(0.0)))) {
        /*
         * nrows = 111;
         */
        mlfAssign(&nrows, mlfScalar(111.0));
        /*
         * narg = 1;
         */
        mlfAssign(&narg, mlfScalar(1.0));
    /*
     * end
     */
    }
    /*
     * 
     * %check for encoded format
     * handle = '';
     */
    mlfAssign(&handle, mxCreateString(""));
    /*
     * position = '';
     */
    mlfAssign(&position, mxCreateString(""));
    /*
     * if narg == 1
     */
    if (mlfTobool(mlfEq(narg, mlfScalar(1.0)))) {
        /*
         * % 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;
         */
        mlfAssign(&code, nrows);
        /*
         * 
         * % turn string into a number:
         * if(isstr(code)) code = str2double(code); end
         */
        if (mlfTobool(mlfIsstr(code))) {
            mlfAssign(&code, mlfStr2double(code));
        }
        /*
         * 
         * % number with a fractional part can only be an identifier:
         * if(rem(code,1) > 0)
         */
        if (mlfTobool(mlfGt(mlfRem(code, mlfScalar(1.0)), mlfScalar(0.0)))) {
            /*
             * handle = code;
             */
            mlfAssign(&handle, code);
            /*
             * if ~strcmp(get(handle,'type'),'axes')
             */
            if (mlfTobool(
                  mlfNot(
                    mlfStrcmp(
                      mlfGet(handle, mxCreateString("type"), NULL),
                      mxCreateString("axes"))))) {
                /*
                 * error('Requires valid axes handle for input.')
                 */
                mlfError(
                  mxCreateString("Requires valid axes handle for input."));
            /*
             * end
             */
            }
            /*
             * create_axis = 0;
             */
            mlfAssign(&create_axis, mlfScalar(0.0));
        /*
         * % all other numbers will be converted to mnp format:
         * else
         */
        } else {
            /*
             * thisPlot = rem(code, 10);
             */
            mlfAssign(&thisPlot, mlfRem(code, mlfScalar(10.0)));
            /*
             * ncols = rem( fix(code-thisPlot)/10,10);
             */
            mlfAssign(
              &ncols,
              mlfRem(
                mlfMrdivide(mlfFix(mlfMinus(code, thisPlot)), mlfScalar(10.0)),
                mlfScalar(10.0)));
            /*
             * nrows = fix(code/100);
             */
            mlfAssign(&nrows, mlfFix(mlfMrdivide(code, mlfScalar(100.0))));
            /*
             * if nrows*ncols < thisPlot
             */
            if (mlfTobool(mlfLt(mlfMtimes(nrows, ncols), thisPlot))) {
                /*
                 * error('Index exceeds number of subplots.');
                 */
                mlfError(mxCreateString("Index exceeds number of subplots."));
            /*
             * end
             */
            }
            /*
             * kill_siblings = 1;
             */
            mlfAssign(&kill_siblings, mlfScalar(1.0));
            /*
             * if(code == 111)
             */
            if (mlfTobool(mlfEq(code, mlfScalar(111.0)))) {
                /*
                 * create_axis   = 0;
                 */
                mlfAssign(&create_axis, mlfScalar(0.0));
                /*
                 * delay_destroy = 1;
                 */
                mlfAssign(&delay_destroy, mlfScalar(1.0));
            /*
             * else
             */
            } else {
                /*
                 * create_axis   = 1;
                 */
                mlfAssign(&create_axis, mlfScalar(1.0));
                /*
                 * delay_destroy = 0;
                 */
                mlfAssign(&delay_destroy, mlfScalar(0.0));
            /*
             * end
             */
            }
        /*
         * end
         */
        }
    /*
     * elseif narg == 2
     */
    } else if (mlfTobool(mlfEq(narg, mlfScalar(2.0)))) {
        /*
         * % The arguments MUST be the string 'position' and a 4-element vector:
         * if(strcmp(lower(nrows), 'position'))
         */
        if (mlfTobool(mlfStrcmp(mlfLower(nrows), mxCreateString("position")))) {
            /*
             * pos_size = size(ncols);
             */
            mlfAssign(&pos_size, mlfSize(mclValueVarargout(), ncols, NULL));
            /*
             * if(pos_size(1) * pos_size(2) == 4)
             */
            if (mlfTobool(
                  mlfEq(
                    mlfMtimes(
                      mlfIndexRef(pos_size, "(?)", mlfScalar(1.0)),
                      mlfIndexRef(pos_size, "(?)", mlfScalar(2.0))),
                    mlfScalar(4.0)))) {
                /*
                 * position = ncols;
                 */
                mlfAssign(&position, ncols);
            /*
             * else
             */
            } else {
                /*
                 * error(['subplot(''position'',',...
                 */
                mlfError(
                  mlfHorzcat(
                    mxCreateString("subplot('position',"),
                    mxCreateString(
                      " [left bottom width height]) is what works"),
                    NULL));
            /*
             * ' [left bottom width height]) is what works'])
             * end
             */
            }
        /*
         * else
         */
        } else {
            /*
             * error('Unknown command option')
             */
            mlfError(mxCreateString("Unknown command option"));
        /*
         * end
         */
        }
        /*
         * kill_siblings = 1; % Kill overlaps here also.
         */
        mlfAssign(&kill_siblings, mlfScalar(1.0));
    /*
     * elseif narg == 3
     */
    } else if (mlfTobool(mlfEq(narg, mlfScalar(3.0)))) {
        /*
         * % passed in subplot(m,n,p) -- we should kill overlaps
         * % here too:
         * kill_siblings = 1;
         */
        mlfAssign(&kill_siblings, mlfScalar(1.0));
    /*
     * end
     */
    }
    /*
     * 
     * % if we recovered an identifier earlier, use it:
     * if(~isempty(handle))
     */
    if (mlfTobool(mlfNot(mlfIsempty(handle)))) {
        /*
         * set(get(0,'CurrentFigure'),'CurrentAxes',handle);
         */
        mclAssignAns(
          &ans,
          mlfNSet(
            0,
            mlfGet(mlfScalar(0.0), mxCreateString("CurrentFigure"), NULL),
            mxCreateString("CurrentAxes"),
            handle,
            NULL));
    /*
     * % if we haven't recovered position yet, generate it from mnp info:
     * elseif(isempty(position))
     */
    } else if (mlfTobool(mlfIsempty(position))) {
        /*
         * if (min(thisPlot) < 1)
         */
        if (mlfTobool(
              mlfLt(mlfMin(NULL, thisPlot, NULL, NULL), mlfScalar(1.0)))) {
            /*
             * error('Illegal plot number.')
             */
            mlfError(mxCreateString("Illegal plot number."));
        /*
         * elseif (max(thisPlot) > ncols*nrows)
         */
        } else if (mlfTobool(
                     mlfGt(
                       mlfMax(NULL, thisPlot, NULL, NULL),
                       mlfMtimes(ncols, nrows)))) {
            /*
             * error('Index exceeds number of subplots.')
             */
            mlfError(mxCreateString("Index exceeds number of subplots."));
        /*
         * else
         */
        } else {
            /*

⌨️ 快捷键说明

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