MEX file that changes all data of a fuzzy model.
MATLAB help:
% MAT2FUZ Changes all data of a fuzzy model.
%
% Final_Model = mat2fuz(Initial_Model,Vector)
%
% Final_Model = mat2fuz(Initial_Model,Vector,Output,Rule)
%
% [Final_Model,length] = mat2fuz(Initial_Model,Vector)
%
% [Final_Model,length] = mat2fuz(Initial_Model,Vector,Output,Rule)
%
% Arguments:
%
% Final_Model -> Changed fuzzy model.
%
% Output -> Use to select the output.
%
% Rule -> Use to select the rule for given output.
%
% length -> The length of Vector, 0 if error.
%
% Initial_Model -> Fuzzy model to change. This model could be a '.txt' file,
% a '.fis' file, or a 'FIS' variable from MATLAB Workspace.
%
% Vector -> Vector with data for fuzzy model.
%
% See also activation, antec2mat, aproxjac, aproxlinear, conseq2mat, fis2txt,
% fuz2mat, fuzcomb, fuzeval, fuzjac, fuzlinear, fuzprint, mat2antec,
% mat2conseq, fuzsubsystem, txt2fis
Source code:
void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
size_t i, length, out, rule;
double *data;
if(nrhs<2)
if (nrhs>2)
{
if (nrhs!=4)
if (mxGetM(prhs[2])>1 || mxGetM(prhs[3])>1)
if (mxGetN(prhs[2])!=mxGetN(prhs[3]))
}
if (nlhs>2)
if (mxIsEmpty(prhs[0]) || mxIsNaN(*mxGetPr(prhs[0])))
data = mxGetPr(prhs[1]);
int error = 0;
if (nrhs==2)
{
}
else
{
length = 0;
for (i=0;i<mxGetN(prhs[2]);i++)
{
out = ((size_t)*(mxGetPr(prhs[2])+i))-1;
rule = ((size_t)*(mxGetPr(prhs[3])+i))-1;
data += numAntec;
data += NoC;
length += numAntec + NoC;
}
}
if (error>0)
{
plhs[0] = mxCreateDoubleMatrix(0,0,mxREAL);
return;
}
if (nlhs==2)
plhs[1] = mxCreateDoubleScalar(length);
const char* names[] = {"name","type","andMethod","orMethod","defuzzMethod","impMethod","aggMethod","input","output","rule"};
mwSize dim[] = {1,1};
plhs[0] = mxCreateStructArray(2,dim,10,names);
{
mxDestroyArray(plhs[0]);
}
}