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, 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
%
% 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, fuzsubsystem
% txt2fis
Source code:
void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
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)
if (nlhs>1)
if (mxIsEmpty(prhs[0]) || mxIsNaN(*mxGetPr(prhs[0])))
if (nrhs>1)
{
d = mxGetPr(prhs[1]);
if (!d)
numMeshPoints = (size_t)(*d);
if (numMeshPoints<2)
if (nrhs>2)
{
d = mxGetPr(prhs[2]);
if (!d)
precision = *d;
if (precision<=0.0)
if (nrhs==4)
{
d=mxGetPr(prhs[3]);
if (!d)
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]);
}
for (j=0;j<aPoints.dim2();j++)
{
for (i=0;i<aPoints.dim1();i++)
{
*Points = aPoints[i][j];
Points++;
}
}
}