plotfa.c

来自「nnToolKit 神经网络工具包是基于 MATLAB 神经网络工具箱自行开发的」· C语言 代码 · 共 309 行

C
309
字号
/*
 * MATLAB Compiler: 3.0
 * Date: Sun May 13 16:47:41 2007
 * Arguments: "-B" "macro_default" "-O" "all" "-O" "fold_scalar_mxarrays:on"
 * "-O" "fold_non_scalar_mxarrays:on" "-O" "optimize_integer_for_loops:on" "-O"
 * "array_indexing:on" "-O" "optimize_conditionals:on" "-M" "-silentsetup" "-d"
 * "d:/MATLAB6p5/work/nnToolKit/src" "-B" "csglcom:nnToolKit,nnToolKit,2.0"
 * "-B" "sgl" "-m" "-W" "main" "-L" "C" "-t" "-T" "link:exe" "-h"
 * "libmmfile.mlib" "-W" "mainhg" "libmwsglm.mlib" "-t" "-W"
 * "comhg:nnToolKit,nnToolKit,2.0" "-T" "link:lib" "-h" "libmmfile.mlib" "-i"
 * "-i" "D:/MATLAB6p5/work/nnToolKit/lmnet/LmSimu.m"
 * "D:/MATLAB6p5/work/nnToolKit/lmnet/LmTrain.m"
 * "D:/MATLAB6p5/work/nnToolKit/sofm/SofmSimu.m"
 * "D:/MATLAB6p5/work/nnToolKit/sofm/SofmTrain.m" 
 */
#include "plotfa.h"
#include "libmatlbm.h"
#include "libmmfile.h"
#include "nntobsf.h"
#include "title.h"
#include "xlabel.h"
#include "ylabel.h"

static mxChar _array1_[6] = { 'b', 'a', 'r', 'e', 'r', 'r' };
static mxArray * _mxarray0_;

static mxChar _array3_[26] = { 'U', 's', 'e', ' ', 'B', 'A', 'R', ' ', 't',
                               'o', ' ', 'm', 'a', 'k', 'e', ' ', 'b', 'a',
                               'r', ' ', 'p', 'l', 'o', 't', 's', '.' };
static mxArray * _mxarray2_;

static mxChar _array5_[21] = { 'N', 'o', 't', ' ', 'e', 'n', 'o',
                               'u', 'g', 'h', ' ', 'a', 'r', 'g',
                               'u', 'm', 'e', 'n', 't', 's', '.' };
static mxArray * _mxarray4_;

static mxChar _array7_[3] = { 'o', 'f', 'f' };
static mxArray * _mxarray6_;

static mxChar _array9_[1] = { '+' };
static mxArray * _mxarray8_;

static mxChar _array11_[2] = { 'o', 'n' };
static mxArray * _mxarray10_;

static mxChar _array13_[1] = { 'm' };
static mxArray * _mxarray12_;

static mxChar _array15_[22] = { 'F', 'u', 'n', 'c', 't', 'i', 'o', 'n',
                                ' ', 'A', 'p', 'p', 'r', 'o', 'x', 'i',
                                'm', 'a', 't', 'i', 'o', 'n' };
static mxArray * _mxarray14_;

static mxChar _array17_[5] = { 'I', 'n', 'p', 'u', 't' };
static mxArray * _mxarray16_;

static mxChar _array19_[21] = { 'O', 'u', 't', 'p', 'u', 't', ':',
                                ' ', '-', ',', ' ', ' ', 'T', 'a',
                                'r', 'g', 'e', 't', ':', ' ', '+' };
static mxArray * _mxarray18_;

void InitializeModule_plotfa(void) {
    _mxarray0_ = mclInitializeString(6, _array1_);
    _mxarray2_ = mclInitializeString(26, _array3_);
    _mxarray4_ = mclInitializeString(21, _array5_);
    _mxarray6_ = mclInitializeString(3, _array7_);
    _mxarray8_ = mclInitializeString(1, _array9_);
    _mxarray10_ = mclInitializeString(2, _array11_);
    _mxarray12_ = mclInitializeString(1, _array13_);
    _mxarray14_ = mclInitializeString(22, _array15_);
    _mxarray16_ = mclInitializeString(5, _array17_);
    _mxarray18_ = mclInitializeString(21, _array19_);
}

void TerminateModule_plotfa(void) {
    mxDestroyArray(_mxarray18_);
    mxDestroyArray(_mxarray16_);
    mxDestroyArray(_mxarray14_);
    mxDestroyArray(_mxarray12_);
    mxDestroyArray(_mxarray10_);
    mxDestroyArray(_mxarray8_);
    mxDestroyArray(_mxarray6_);
    mxDestroyArray(_mxarray4_);
    mxDestroyArray(_mxarray2_);
    mxDestroyArray(_mxarray0_);
}

static mxArray * Mplotfa(int nargout_,
                         mxArray * p1,
                         mxArray * t,
                         mxArray * p2,
                         mxArray * a);

_mexLocalFunctionTable _local_function_table_plotfa
  = { 0, (mexFunctionTableEntry *)NULL };

/*
 * The function "mlfNPlotfa" contains the nargout interface for the "plotfa"
 * M-function from file "d:\matlab6p5\toolbox\nnet\nnobsolete\plotfa.m" (lines
 * 1-35). 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 * mlfNPlotfa(int nargout,
                     mxArray * p1,
                     mxArray * t,
                     mxArray * p2,
                     mxArray * a) {
    mxArray * h = NULL;
    mlfEnterNewContext(0, 4, p1, t, p2, a);
    h = Mplotfa(nargout, p1, t, p2, a);
    mlfRestorePreviousContext(0, 4, p1, t, p2, a);
    return mlfReturnValue(h);
}

/*
 * The function "mlfPlotfa" contains the normal interface for the "plotfa"
 * M-function from file "d:\matlab6p5\toolbox\nnet\nnobsolete\plotfa.m" (lines
 * 1-35). This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
mxArray * mlfPlotfa(mxArray * p1, mxArray * t, mxArray * p2, mxArray * a) {
    int nargout = 1;
    mxArray * h = NULL;
    mlfEnterNewContext(0, 4, p1, t, p2, a);
    h = Mplotfa(nargout, p1, t, p2, a);
    mlfRestorePreviousContext(0, 4, p1, t, p2, a);
    return mlfReturnValue(h);
}

/*
 * The function "mlfVPlotfa" contains the void interface for the "plotfa"
 * M-function from file "d:\matlab6p5\toolbox\nnet\nnobsolete\plotfa.m" (lines
 * 1-35). 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 mlfVPlotfa(mxArray * p1, mxArray * t, mxArray * p2, mxArray * a) {
    mxArray * h = NULL;
    mlfEnterNewContext(0, 4, p1, t, p2, a);
    h = Mplotfa(0, p1, t, p2, a);
    mlfRestorePreviousContext(0, 4, p1, t, p2, a);
    mxDestroyArray(h);
}

/*
 * The function "mlxPlotfa" contains the feval interface for the "plotfa"
 * M-function from file "d:\matlab6p5\toolbox\nnet\nnobsolete\plotfa.m" (lines
 * 1-35). The feval function calls the implementation version of plotfa through
 * this function. This function processes any input arguments and passes them
 * to the implementation version of the function, appearing above.
 */
void mlxPlotfa(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: plotfa Line: 1 Column: "
            "1 The function \"plotfa\" was called with mor"
            "e than the declared number of outputs (1)."),
          NULL);
    }
    if (nrhs > 4) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: plotfa Line: 1 Column: "
            "1 The function \"plotfa\" was called with mor"
            "e than the declared number of inputs (4)."),
          NULL);
    }
    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] = Mplotfa(nlhs, mprhs[0], mprhs[1], mprhs[2], mprhs[3]);
    mlfRestorePreviousContext(0, 4, mprhs[0], mprhs[1], mprhs[2], mprhs[3]);
    plhs[0] = mplhs[0];
}

/*
 * The function "Mplotfa" is the implementation version of the "plotfa"
 * M-function from file "d:\matlab6p5\toolbox\nnet\nnobsolete\plotfa.m" (lines
 * 1-35). 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 = plotfa(p1,t,p2,a)
 */
static mxArray * Mplotfa(int nargout_,
                         mxArray * p1,
                         mxArray * t,
                         mxArray * p2,
                         mxArray * a) {
    mexLocalFunctionTable save_local_function_table_
      = mclSetCurrentLocalFunctionTable(&_local_function_table_plotfa);
    int nargin_ = mclNargin(4, p1, t, p2, a, NULL);
    mxArray * h = NULL;
    mxArray * ans = NULL;
    mclCopyArray(&p1);
    mclCopyArray(&t);
    mclCopyArray(&p2);
    mclCopyArray(&a);
    /*
     * %PLOTFA Plot data points and network function approximation.
     * %  
     * %  This function is obselete.
     * 
     * nntobsf('barerr','Use BAR to make bar plots.')
     */
    mlfNntobsf(_mxarray0_, _mxarray2_, NULL);
    /*
     * 
     * %  PLOTFA(P1,T,P2,A)
     * %    P1 - 1xQ1 vector of input values.
     * %    T  - 1xQ1 vector of targets associated with P1.
     * %    P2 - 1xQ2 vector of input values.
     * %    A  - 1xQ2 vector of network outputs associated with P2.
     * %  Plots T with respect to P1 with yellow '+' markers.
     * %  Plots A with respect to P2 with solid magenta line.
     * 
     * % Mark Beale, 1-31-92.
     * % Revised 12-15-93, MB.
     * % Copyright 1992-2002 The MathWorks, Inc.
     * % $Revision: 1.12 $
     * 
     * if nargin < 4, error('Not enough arguments.'); end
     */
    if (nargin_ < 4) {
        mlfError(_mxarray4_, NULL);
    }
    /*
     * 
     * hold off;
     */
    mlfHold(_mxarray6_);
    /*
     * plot(p1,t,'+');
     */
    mclAssignAns(
      &ans, mlfNPlot(0, mclVa(p1, "p1"), mclVa(t, "t"), _mxarray8_, NULL));
    /*
     * hold on;
     */
    mlfHold(_mxarray10_);
    /*
     * if nargout
     */
    if (nargout_ != 0) {
        /*
         * h = plot(p2,a,'m');
         */
        mlfAssign(
          &h, mlfNPlot(1, mclVa(p2, "p2"), mclVa(a, "a"), _mxarray12_, NULL));
    /*
     * else
     */
    } else {
        /*
         * plot(p2,a,'m');
         */
        mclAssignAns(
          &ans, mlfNPlot(0, mclVa(p2, "p2"), mclVa(a, "a"), _mxarray12_, NULL));
    /*
     * end
     */
    }
    /*
     * title('Function Approximation')
     */
    mclPrintAns(&ans, mlfNTitle(0, _mxarray14_, NULL));
    /*
     * xlabel('Input')
     */
    mclPrintAns(&ans, mlfNXlabel(0, _mxarray16_, NULL));
    /*
     * ylabel('Output: -,  Target: +')
     */
    mclPrintAns(&ans, mlfNYlabel(0, _mxarray18_, NULL));
    /*
     * drawnow
     */
    mlfDrawnow(NULL);
    mclValidateOutput(h, 1, nargout_, "h", "plotfa");
    mxDestroyArray(ans);
    mxDestroyArray(a);
    mxDestroyArray(p2);
    mxDestroyArray(t);
    mxDestroyArray(p1);
    mclSetCurrentLocalFunctionTable(save_local_function_table_);
    return h;
}

⌨️ 快捷键说明

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