MEX file that gets the jacobian matrix of a fuzzy model with respect to its parameters.
MATLAB help:
% FUZDERPARAM Gets the
jacobian matrix of a fuzzy model respect its parameters.
%
% dh_dparam = fuzderparam(Fuzzy_Model, Point)
%
% Arguments:
%
% Fuzzy_Model -> This fuzzy model could be a '.txt' file, a '.fis' file,
% or a 'FIS' variable from MATLAB Workspace.
%
% Point -> Point where the derivative will be calculate.
%
% See also activation, antec2mat, aproxjac, aproxlinear, conseq2mat, fis2txt,
% fuz2mat, fuzcomb, fuzderconseq, fuzeval, fuzjac, fuzlinear, fuzprint,
% mat2antec, mat2conseq, mat2fuz, fuzsubsystem, txt2fis
Source code:
void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
size_t input, output, rule, param, m;
int error=0;
double *Point, *dModel_dparam;
if(nrhs!=2)
if (nlhs>1)
for (int i=0;i<nrhs;i++)
{
if (mxIsEmpty(prhs[i]) || mxIsNaN(*mxGetPr(prhs[i])))
}
if (1 != mxGetN(prhs[1]))
if (S.
inputs() != mxGetM(prhs[1]))
Point = mxGetPr(prhs[1]);
if (!plhs[0])
dModel_dparam = mxGetPr(plhs[0]);
TNT::Array2D<double> dS_dparam =
derfuzzy(S, Point);
if (dS_dparam.dim1()==0 || dS_dparam.dim2()==0 )
{
mxDestroyArray(plhs[0]);
}
for (size_t j=0;j<dS_dparam.dim2();j++)
{
for (size_t i=0;i<dS_dparam.dim1();i++)
{
*dModel_dparam = dS_dparam[i][j];
dModel_dparam++;
}
}
}