| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Fuzzy Logic Toolbox |
| Contents | Index |
| Learn more about Fuzzy Logic Toolbox |
Fuzzy Logic Toolbox software provides a stand-alone C code fuzzy inference engine. You can use the engine as an alternative tool to simulate the outputs of your fuzzy inference system (FIS), without using the MATLAB environment. You can perform the following tasks using the fuzzy inference engine:
Perform fuzzy inference using a FIS structure file and an input data file.
To learn more about how to create a FIS structure file, see Building Systems with Fuzzy Logic Toolbox Software.
Customize the fuzzy inference engine to include your own membership functions.
Embed the executable code in other external applications.
The stand-alone fuzzy inference engine consists of two C code source files fismain.c and fis.c in the matlabroot\toolbox\fuzzy\fuzzy folder.
The fismain.c file contains only the main() function and you can easily modify it to adapt to other applications. It is ANSI C compatible, and you can compile it with any ANSI C compiler.
The fis.c file contains all the necessary functions to perform the fuzzy inference process:
This file provides the 11 Fuzzy Logic Toolbox membership functions with their default settings.
You can add a new membership function or new reasoning mechanism by updating the fis.c file.
The fismain executable code, generated after compiling the source codes, reads an input data file and a FIS structure file to simulate the output. The syntax for calling fismain is similar to its MEX-file counterpart evalfis, except that all matrices are replaced with files. To learn more about evalfis, see the evalfis function reference page.
This example demonstrates how to simulate a fuzzy inference system on a Windows® platform using the stand-alone fuzzy inference engine. In this example, you use the LCC C compiler shipped with MATLAB to compile the fuzzy inference engine source codes.
Open a DOS Command Window and change the folder to matlabroot\toolbox\fuzzy\fuzzy.
In the DOS Command Window, type the following command:
lcc -c fismain.c
This command creates the fismain.obj object file in the matlabroot\toolbox\fuzzy\fuzzy folder.
Note You may encounter the following error when executing the lcc command: 'lcc' is not recognized as an internal or external command, operable program or batch file. To learn how to troubleshoot this error, see the Including the lcc Command in the PATH Environment Variable section. |
In the DOS Command Window, type the following command:
lcclnk fismain.obj.
This command creates an executable file fismain.exe in the matlabroot\toolbox\fuzzy\fuzzy folder.
Note You may encounter the following error when executing the lcclnk command: 'lcclnk' is not recognized as an internal or external command, operable program or batch file. To learn how to troubleshoot this error, see the Including the lcclnk Command in the PATH Environment Variable section. |
Open MATLAB desktop, and change to your current working folder using the Current Folder field in the MATLAB desktop toolbar.
At the MATLAB prompt, type the following command to create an input data file:
[x, y] = meshgrid(-5:5, -5:5); input_data = [x(:) y(:)]; save fis_in input_data -ascii
This command saves the input data as a 121-by-2 matrix in the fis_in ASCII file in your current working folder. Each row of the matrix represents an input vector.
Copy the FIS structure file mam21.fis from the matlabroot\toolbox\fuzzy\fuzdemos folder to your current working folder.
Copy the stand-alone executable file fismain.exe from the matlabroot\toolbox\fuzzy\fuzzy folder to your current working folder.
In the DOS Command Window, change the folder to your current working folder, and type the following command to call the stand-alone executable code:
fismain fis_in mam21.fis
This command uses the data file fis_in and the FIS structure file mam21.fis, and generates 121 outputs on your screen.
To verify that the fuzzy inference engine output matches the MATLAB MEX-file evalfis.m output, type the following command at the MATLAB prompt:
fismat = readfis('mam21');
matlab_out = evalfis(input_data, fismat);
load fis_out
max(max(matlab_out - fis_out))
This command returns the following result:
ans = 4.9583e-013
The difference results from the relative precision between the outputs.
When executing the lcc command to create the fismain.obj object file, you get the following error if the command and/or the path for the <include> header files are not in the PATH environment variable:
'lcc' is not recognized as an internal or external command, operable program or batch file.
To include the command in the PATH environment variable, type the following in the DOS Command Window:
matlabroot\sys\lcc\bin\lcc -Imatlabroot\sys\lcc\include fismain.c
Press Enter when prompted to Please enter the path for the <include> header files.
When executing the lcclnk command to create the fismain.exe file, you get the following error if the command is not in the PATH environment variable:
'lcclnk' is not recognized as an internal or external command, operable program or batch file.
To include the command in the PATH environment variable, type the following in the DOS Command Window:
matlabroot\sys\lcc\bin\lcclnk fismain.obj
This example demonstrates how to simulate a fuzzy inference system on a UNIX® platform using the stand-alone fuzzy inference engine.
Open a UNIX Command Window and change the folder to matlabroot\toolbox\fuzzy\fuzzy.
In the UNIX Command Window, type the following command:
cc -O -o fismain fismain.c -lm
This command creates the fismain file in the matlabroot\toolbox\fuzzy\fuzzy folder.
The fis.c file is included in the fismain.c file; you do not have to compile it separately.
At the MATLAB prompt, create an input data file using the following command:
[x, y] = meshgrid(-5:5, -5:5); input_data = [x(:) y(:)]; save fis_in input_data -ascii
This command saves the input data as a 121-by-2 matrix in the ASCII file fis_in in your current working folder. Each row of the matrix represents an input vector.
Copy the FIS structure file mam21.fis from the matlabroot\toolbox\fuzzy\fuzdemos folder to your current working folder.
Copy the fismain file from the matlabroot\toolbox\fuzzy\fuzzy folder to your current working folder.
In the UNIX Command Window, change the folder to your current working folder, and type the following executable command:
fismain fis_in mam21.fis
This command uses the data file fis_in and the FIS structure file mam21.fis and generates 121 outputs on your screen.
To verify that the fuzzy inference engine output matches the MATLAB MEX-file evalfis.m output, type the following command at the MATLAB prompt:
fismat = readfis('mam21');
matlab_out = evalfis(input_data, fismat);
load fis_out
max(max(matlab_out - fis_out))
This command returns the following result:
ans = 4.9583e-013
The difference results from the relative precision between the outputs.
![]() | Fuzzy Clustering | Function Reference | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |