Fuzzy Logic Toolbox | ![]() ![]() |
Stand-Alone C-Code Fuzzy Inference Engine
In the fuzzy/fuzzy directory of the toolbox, you can find two C files, fismain.c and fis.c, which are provided as the source codes for a stand-alone fuzzy inference engine. The stand-alone C-code fuzzy inference engine can read an FIS file and an input data file to perform fuzzy inference directly, or it can be embedded in other external applications.
To compile the stand-alone fuzzy inference engine on a UNIX system, type
(Note that %
is only symbolic of a UNIX prompt, and that you do not have to type fis.c explicitly, since it is included in fismain.c.) Upon successful compilation, type the executable command to see how it works.
This prompts the following message.
This means that fismain needs two files to do its work: a data file containing rows of input vectors, and an FIS file that specifies the fuzzy inference system under consideration.
For example, consider an FIS structure file named, mam21.fis. We can prepare the input data file using MATLAB.
This saves all the input data as a 121-by-2 matrix in the ASCII file fis_in, where each row of the matrix represents an input vector.
Now we can call the stand-alone code.
This generates 121 outputs on your screen. You can direct the outputs to another file.
Now the file fis_out contains a 121-by-1 matrix. In general, each row of the output matrix represents an output vector. The syntax of fismain is similar to its MEX-file counterpart evalfis.m, except that all matrices are replaced with files.
To compare the results from the MATLAB MEX-file and the stand-alone executable, type the following within MATLAB.
fismat = readfis('mam21'); matlab_out = evalfis(input_data, fismat); load fis_out max(max(matlab_out - fis_out)) ans = 4.9583e-13
This tiny difference comes from the limited length printout in the file fis_out. There are several things you should know about this stand-alone executable:
![]() | Subtractive Clustering | Function Reference | ![]() |