Fuzzy Logic Tools  v1.0.5.1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
matlab_utilities/initializeController.cpp

MEX file that initializes a fuzzy Controller from a fuzzy Plant.

MATLAB help:

% INITIALIZECONTROLLER Initializes a fuzzy Controller from a fuzzy Plant.
%
% Controller = initializeController(Plant)
%
% Arguments:
%
% Plant -> Plant model. This model could be a '.txt' file, a '.fis' file,
% or a 'FIS' variable from MATLAB Workspace.
%
% Controller -> An initial controller based in the Plant. This controller
% has all its consecuents to 0, and each of its outputs have
% so many rules as all of the plant.
%
% See also activation, antec2mat, aproxjac, aproxlinear, conseq2mat, fis2txt,
% fuz2mat,fuzcomb, fuzeval, fuzjac, fuzlinear, fuzprint, mat2antec,
% mat2conseq, mat2fuz, fuzsubsystem, 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];
if(nrhs!=1)
ERRORMSG(E_NumberArgIn)
if (nlhs>1)
ERRORMSG(E_NumberArgOut)
if (mxIsEmpty(prhs[0]) || mxIsNaN(*mxGetPr(prhs[0])))
ERRORMSG(E_ArgNoValid)
System P,C;
if (readModel(prhs[0],P))
ERRORMSG(E_Model)
if (!C.outputs())
{
mexErrMsgTxt("The input fuzzy model is not a valid Plant\n");
return;
}
const char* names[]={"name","type","andMethod","orMethod","defuzzMethod","impMethod","aggMethod","input","output","rule"};
mwSize dim[] = {1,1};
plhs[0] = mxCreateStructArray(2,dim,10,names);
if(System2FIS(C,plhs[0]))
{
mxDestroyArray(plhs[0]);
ERRORMSG(E_FISOut)
}
}