📄 plotsm.c
字号:
/*
* 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 "plotsm.h"
#include "libmatlbm.h"
#include "libmmfile.h"
#include "nntobsf.h"
#include "xlabel.h"
#include "ylabel.h"
static mxChar _array1_[7] = { 'a', 'd', 'a', 'p', 't', 'w', 'h' };
static mxArray * _mxarray0_;
static mxChar _array3_[55] = { 'U', 's', 'e', ' ', 'N', 'N', 'T', '2', 'L', 'I',
'N', ' ', 'a', 'n', 'd', ' ', 'A', 'D', 'A', 'P',
'T', ' ', 't', 'o', ' ', 'u', 'p', 'd', 'a', 't',
'e', ' ', 'a', 'n', 'd', ' ', 'a', 'd', 'a', 'p',
't', ' ', 'y', 'o', 'u', 'r', ' ', 'n', 'e', 't',
'w', 'o', 'r', 'k', '.' };
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 mxArray * _mxarray6_;
static mxChar _array8_[33] = { 'W', ' ', 'm', 'u', 's', 't', ' ', 'h', 'a',
'v', 'e', ' ', 'a', 't', ' ', 'l', 'e', 'a',
's', 't', ' ', 't', 'w', 'o', ' ', 'c', 'o',
'l', 'u', 'm', 'n', 's', '.' };
static mxArray * _mxarray7_;
static mxChar _array10_[3] = { 'b', 'o', 'x' };
static mxArray * _mxarray9_;
static mxChar _array12_[2] = { 'o', 'n' };
static mxArray * _mxarray11_;
static mxChar _array14_[6] = { 'W', '(', 'i', ',', '1', ')' };
static mxArray * _mxarray13_;
static mxChar _array16_[6] = { 'W', '(', 'i', ',', '2', ')' };
static mxArray * _mxarray15_;
static mxArray * _mxarray17_;
static mxArray * _mxarray18_;
static mxArray * _mxarray19_;
static mxChar _array21_[1] = { 'b' };
static mxArray * _mxarray20_;
static mxChar _array23_[2] = { '.', 'r' };
static mxArray * _mxarray22_;
static mxChar _array25_[10] = { 'm', 'a', 'r', 'k', 'e',
'r', 's', 'i', 'z', 'e' };
static mxArray * _mxarray24_;
static mxArray * _mxarray26_;
static mxChar _array28_[3] = { 'o', 'f', 'f' };
static mxArray * _mxarray27_;
void InitializeModule_plotsm(void) {
_mxarray0_ = mclInitializeString(7, _array1_);
_mxarray2_ = mclInitializeString(55, _array3_);
_mxarray4_ = mclInitializeString(21, _array5_);
_mxarray6_ = mclInitializeDouble(2.0);
_mxarray7_ = mclInitializeString(33, _array8_);
_mxarray9_ = mclInitializeString(3, _array10_);
_mxarray11_ = mclInitializeString(2, _array12_);
_mxarray13_ = mclInitializeString(6, _array14_);
_mxarray15_ = mclInitializeString(6, _array16_);
_mxarray17_ = mclInitializeDoubleVector(0, 0, (double *)NULL);
_mxarray18_ = mclInitializeDouble(1.1);
_mxarray19_ = mclInitializeDouble(1.0);
_mxarray20_ = mclInitializeString(1, _array21_);
_mxarray22_ = mclInitializeString(2, _array23_);
_mxarray24_ = mclInitializeString(10, _array25_);
_mxarray26_ = mclInitializeDouble(20.0);
_mxarray27_ = mclInitializeString(3, _array28_);
}
void TerminateModule_plotsm(void) {
mxDestroyArray(_mxarray27_);
mxDestroyArray(_mxarray26_);
mxDestroyArray(_mxarray24_);
mxDestroyArray(_mxarray22_);
mxDestroyArray(_mxarray20_);
mxDestroyArray(_mxarray19_);
mxDestroyArray(_mxarray18_);
mxDestroyArray(_mxarray17_);
mxDestroyArray(_mxarray15_);
mxDestroyArray(_mxarray13_);
mxDestroyArray(_mxarray11_);
mxDestroyArray(_mxarray9_);
mxDestroyArray(_mxarray7_);
mxDestroyArray(_mxarray6_);
mxDestroyArray(_mxarray4_);
mxDestroyArray(_mxarray2_);
mxDestroyArray(_mxarray0_);
}
static void Mplotsm(mxArray * w, mxArray * m);
_mexLocalFunctionTable _local_function_table_plotsm
= { 0, (mexFunctionTableEntry *)NULL };
/*
* The function "mlfPlotsm" contains the normal interface for the "plotsm"
* M-function from file "d:\matlab6p5\toolbox\nnet\nnobsolete\plotsm.m" (lines
* 1-55). This function processes any input arguments and passes them to the
* implementation version of the function, appearing above.
*/
void mlfPlotsm(mxArray * w, mxArray * m) {
mlfEnterNewContext(0, 2, w, m);
Mplotsm(w, m);
mlfRestorePreviousContext(0, 2, w, m);
}
/*
* The function "mlxPlotsm" contains the feval interface for the "plotsm"
* M-function from file "d:\matlab6p5\toolbox\nnet\nnobsolete\plotsm.m" (lines
* 1-55). The feval function calls the implementation version of plotsm through
* this function. This function processes any input arguments and passes them
* to the implementation version of the function, appearing above.
*/
void mlxPlotsm(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
mxArray * mprhs[2];
int i;
if (nlhs > 0) {
mlfError(
mxCreateString(
"Run-time Error: File: plotsm Line: 1 Column: "
"1 The function \"plotsm\" was called with mor"
"e than the declared number of outputs (0)."),
NULL);
}
if (nrhs > 2) {
mlfError(
mxCreateString(
"Run-time Error: File: plotsm Line: 1 Column: "
"1 The function \"plotsm\" was called with mor"
"e than the declared number of inputs (2)."),
NULL);
}
for (i = 0; i < 2 && i < nrhs; ++i) {
mprhs[i] = prhs[i];
}
for (; i < 2; ++i) {
mprhs[i] = NULL;
}
mlfEnterNewContext(0, 2, mprhs[0], mprhs[1]);
Mplotsm(mprhs[0], mprhs[1]);
mlfRestorePreviousContext(0, 2, mprhs[0], mprhs[1]);
}
/*
* The function "Mplotsm" is the implementation version of the "plotsm"
* M-function from file "d:\matlab6p5\toolbox\nnet\nnobsolete\plotsm.m" (lines
* 1-55). 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 plotsm(w,m)
*/
static void Mplotsm(mxArray * w, mxArray * m) {
mexLocalFunctionTable save_local_function_table_
= mclSetCurrentLocalFunctionTable(&_local_function_table_plotsm);
int nargin_ = mclNargin(2, w, m, NULL);
mxArray * len = NULL;
mxArray * ind = NULL;
mxArray * j = NULL;
mxArray * i = NULL;
mxArray * R = NULL;
mxArray * S = NULL;
mxArray * ans = NULL;
mclCopyArray(&w);
mclCopyArray(&m);
/*
* %PLOTSM Plot weights vectors of self-organizing map.
* %
* %
* % This function is obselete.
* % Use PLOTSOM to plot a self-organizing map.
*
* nntobsf('adaptwh','Use NNT2LIN and ADAPT to update and adapt your network.')
*/
mlfNntobsf(_mxarray0_, _mxarray2_, NULL);
/*
*
* % PLOTSM(W,M)
* % W - RxS matrix of weight vectors.
* % M - Neighborhood matrix.
* % Plots each neurons weight vector as a dot, and connects
* % neighboring neurons weight vectors with lines.
* %
* % EXAMPLES: W = rands(12,2);
* % M = nbman(3,4);
* % plotsm(W,M)
* %
* % [x,y] = meshgrid(1:5,1:6);
* % W = [x(:) y(:)];
* % M = nbman(5,6);
* % plotsm(W,M)
* %
* % See also NBGRID, NBMAN, NBDIST.
*
* % Mark Beale, 12-15-93
* % Copyright 1992-2002 The MathWorks, Inc.
* % $Revision: 1.11 $ $Date: 2002/03/25 16:54:08 $
*
* if nargin < 2, error('Not enough arguments.'),end
*/
if (nargin_ < 2) {
mlfError(_mxarray4_, NULL);
}
/*
*
* [S,R] = size(w);
*/
mlfSize(mlfVarargout(&S, &R, NULL), mclVa(w, "w"), NULL);
/*
* if R < 2,error('W must have at least two columns.'),end
*/
if (mclLtBool(mclVv(R, "R"), _mxarray6_)) {
mlfError(_mxarray7_, NULL);
}
/*
*
* newplot;
*/
mclAssignAns(&ans, mlfNNewplot(0, NULL));
/*
* set(gca,'box','on')
*/
mclPrintAns(&ans, mlfNSet(0, mlfGca(NULL), _mxarray9_, _mxarray11_, NULL));
/*
* hold on
*/
mlfHold(_mxarray11_);
/*
* xlabel('W(i,1)');
*/
mclAssignAns(&ans, mlfNXlabel(0, _mxarray13_, NULL));
/*
* ylabel('W(i,2)');
*/
mclAssignAns(&ans, mlfNYlabel(0, _mxarray15_, NULL));
/*
*
* % CONNECT WEIGHT VECTORS
* for i=1:(S-1)
*/
{
int v_ = mclForIntStart(1);
int e_ = mclForIntEnd(mclMinus(mclVv(S, "S"), _mxarray19_));
if (v_ > e_) {
mlfAssign(&i, _mxarray17_);
} else {
/*
* j=(i+1):S;
* ind = find(m(i,j) <= 1.1);
* j = j(ind);
* len = length(j);
* plot([ones(len,1)*w(i,1) w(j,1)]',[ones(len,1)*w(i,2)' w(j,2)]','b');
* end
*/
for (; ; ) {
mlfAssign(&j, mlfColon(mlfScalar(v_ + 1), mclVv(S, "S"), NULL));
mlfAssign(
&ind,
mlfFind(
NULL,
NULL,
mclLe(
mclArrayRef2(mclVa(m, "m"), mlfScalar(v_), mclVv(j, "j")),
_mxarray18_)));
mlfAssign(&j, mclArrayRef1(mclVv(j, "j"), mclVv(ind, "ind")));
mlfAssign(&len, mlfScalar(mclLengthInt(mclVv(j, "j"))));
mclAssignAns(
&ans,
mlfNPlot(
0,
mlfCtranspose(
mlfHorzcat(
mclMtimes(
mlfOnes(mclVv(len, "len"), _mxarray19_, NULL),
mclIntArrayRef2(mclVa(w, "w"), v_, 1)),
mclArrayRef2(mclVa(w, "w"), mclVv(j, "j"), _mxarray19_),
NULL)),
mlfCtranspose(
mlfHorzcat(
mlf_times_transpose(
mlfOnes(mclVv(len, "len"), _mxarray19_, NULL),
mclIntArrayRef2(mclVa(w, "w"), v_, 2),
_mxarray6_),
mclArrayRef2(mclVa(w, "w"), mclVv(j, "j"), _mxarray6_),
NULL)),
_mxarray20_,
NULL));
if (v_ == e_) {
break;
}
++v_;
}
mlfAssign(&i, mlfScalar(v_));
}
}
/*
*
* % PLOT WEIGHT VECTORS
* plot(w(:,1),w(:,2),'.r','markersize',20)
*/
mclPrintAns(
&ans,
mlfNPlot(
0,
mclArrayRef2(mclVa(w, "w"), mlfCreateColonIndex(), _mxarray19_),
mclArrayRef2(mclVa(w, "w"), mlfCreateColonIndex(), _mxarray6_),
_mxarray22_,
_mxarray24_,
_mxarray26_,
NULL));
/*
* hold off
*/
mlfHold(_mxarray27_);
/*
* drawnow
*/
mlfDrawnow(NULL);
mxDestroyArray(ans);
mxDestroyArray(S);
mxDestroyArray(R);
mxDestroyArray(i);
mxDestroyArray(j);
mxDestroyArray(ind);
mxDestroyArray(len);
mxDestroyArray(m);
mxDestroyArray(w);
mclSetCurrentLocalFunctionTable(save_local_function_table_);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -