getFISCodeGenerationData

Create homogeneous fuzzy inference system structure

Description

To generate code for evaluating a fuzzy inference system using MATLAB® Coder™, you must convert your fuzzy inference system object into a homogeneous structure using getFISCodeGenerationData.

example

fisOut = getFISCodeGenerationData(fisIn) converts a type-1 fuzzy inference system fisIn into a homogeneous structure fisOut. fisIn can be a FIS object or the name of a .fis file.

example

fisOut = getFISCodeGenerationData(fisIn,'FuzzySetType',setType) specifies the type of membership functions used in fisIn.

Examples

collapse all

Create a fuzzy inference system. For this example, load a fuzzy system from a file.

fisObject = readfis('tipper');

Convert the resulting mamfis object into a homogeneous structure.

fisStructure = getFISCodeGenerationData(fisObject);

In this structure, if a field is a structure array, all the elements of that array are the same size. For example, consider the elements of input variable array fisStructure.input.

fisStructure.input(1)
ans = struct with fields:
              name: 'service'
    origNameLength: 7
             range: [0 10]
                mf: [1x3 struct]
         origNumMF: 3

fisStructure.input(2)
ans = struct with fields:
              name: 'food   '
    origNameLength: 4
             range: [0 10]
                mf: [1x3 struct]
         origNumMF: 2

The name fields are character vectors of the same length. Also, even though the second input variable has only two membership functions, the mf fields both contain three membership function structures. The original number of membership functions for a given input variable is stored in the origNumMF field.

Load the fuzzy inference system saved in the file tipper.fis into a homogeneous structure.

fis = getFISCodeGenerationData('tipper.fis');

Create a type-2 fuzzy inference system. For this example,create a default FIS with three inputs and two outputs.

fisObject = mamfistype2('NumInputs',3,'NumOutputs',2);

Convert the resulting mamfistype2 object into a homogeneous structure.

fisStructure = getFISCodeGenerationData(fisObject,'FuzzySetType',"type2");

Input Arguments

collapse all

Input fuzzy inference system, specified as one of the following:

  • mamfis, sugfis, mamfistype2, or sugfistype2 object. getFISCodeGenerationData supports fuzzy inference system objects for simulation only.

  • String or character vector specifying a .fis file in the current working folder or on the MATLAB path. getFISCodeGenerationData supports fuzzy inference system file names for both simulation and code generation.

If fisIn is either a mamfistype2 or sugfistype2 object, then you must specify the setType as "type2".

When getFISCodeGenerationData loads a fuzzy system that uses custom functions, it writes additional files to the current folder to support code generation for the custom functions.

Type of membership functions used in fisIn, specified as one of the following:

  • "type1" — Type-1 membership functions

  • "type2" — Type-2 membership functions

Output Arguments

collapse all

Output fuzzy inference system, returned as a homogeneous structure. In the homogeneous structure, if a field is a structure array, all the elements of that array are the same size. For example, in the input variable array fisOut.input:

  • Names of all the variables are character vectors of the same length.

  • Lengths of the membership function arrays for all variables are the same.

For any character vectors or structure arrays that are padded to increase their lengths, the original lengths of these elements are saved within the structure.

The fisOut structure is different than the structure created using convertToStruct.

Extended Capabilities

Introduced in R2018b