|
Fuzzy Logic Tools v1.0
|
MEX file that extracts the significative points of a fuzzy model.
MATLAB help:
% EXTRACTPOINTS Extracts the significative points of a fuzzy model. % % Points = extractPoints(System) % % Points = extractPoints(System, numMeshPoints) % % Points = extractPoints(System, numMeshPoints, precision) % % Points = extractPoints(System, numMeshPoints, precision, controlPoints) % % Arguments: % % System -> This fuzzy model could be a '.txt' file, a '.fis' file, % or a 'FIS' variable from MATLAB Workspace. % % numMeshPoints -> Used in memberships functions without significative % points (ANYMF, CONSTMF, ...). Default value is 5. % % precision -> Used to remove similar points. Default value is 1e-3. % % controlPoints -> If controlPoints>0 extract all point, otherwise, only % extracts the state vector points, not the control vector points. % Default value is 0 (do not extract the control vector points). % % See also activation, antec2mat, aproxjac, aproxlinear, conseq2mat, fis2txt, % fuz2mat,fuzcomb, fuzeval, fuzjac, fuzlinear, fuzprint, % initializeController, mat2antec, mat2conseq, mat2fuz, subsystem % txt2fis
Source code:
/* Copyright (C) 2004-2011 ANTONIO JAVIER BARRAGAN, antonio.barragan@diesia.uhu.es http://uhu.es/antonio.barragan Collaborators: JOSE MANUEL ANDUJAR, andujar@diesia.uhu.es MARIANO J. AZNAR, marianojose.aznar@alu.uhu.es DPTO. DE ING. ELECTRONICA, DE SISTEMAS INFORMATICOS Y AUTOMATICA ETSI, UNIVERSITY OF HUELVA (SPAIN) For more information, please contact with authors. This software is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "aux_matlab.hpp" using namespace FLT; void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { char file[MAX_CHAR_LONG]; size_t i,j; int error = 0; size_t numMeshPoints = 5; double precision = 1E-3; bool onlyStatePoints = true; double *d; if(nrhs<1 || nrhs>4) ERRORMSG(E_NumberArgIn) if (nlhs>1) ERRORMSG(E_NumberArgOut) if (mxIsEmpty(prhs[0]) || mxIsNaN(*mxGetPr(prhs[0]))) ERRORMSG(E_ArgNoValid) System S; if (readModel(prhs[0],S)) ERRORMSG(E_Model) if (nrhs>1) { d = mxGetPr(prhs[1]); if (!d) ERRORMSG(E_NumberArgIn) numMeshPoints = (size_t)(*d); if (numMeshPoints<2) ERRORMSG(E_N_MESH_P) if (nrhs>2) { d = mxGetPr(prhs[2]); if (!d) ERRORMSG(E_NumberArgIn) precision = *d; if (precision<=0.0) ERRORMSG(E_PRECISION) if (nrhs==4) { d=mxGetPr(prhs[3]); if (!d) ERRORMSG(E_NumberArgIn) onlyStatePoints = (*d<=0.0); } } } TNT::Array2D<double> aPoints = extractPoints(S,numMeshPoints,precision,onlyStatePoints); plhs[0] = mxCreateDoubleMatrix(aPoints.dim1(),aPoints.dim2(),mxREAL); double *Points = mxGetPr(plhs[0]); if (!Points) { mxDestroyArray(plhs[0]); ERRORMSG(E_NumberArgOut) } for (j=0;j<aPoints.dim2();j++) { for (i=0;i<aPoints.dim1();i++) { *Points = aPoints[i][j]; Points++; } } }
1.7.4