Main Content


(To be removed) Generate fuzzy inference system from data using FCM clustering

    genfis3 will be removed in a future release. Use genfis instead. For more information, see Compatibility Considerations.


    fis = genfis3(inputData,outputData) creates a Sugeno FIS using fuzzy c-means (FCM) clustering by extracting a set of rules that models the training data behavior.

    fis = genfis3(inputData,outputData,type) generates a FIS of the specified type, either Mamdani or Sugeno.


    fis = genfis3(inputData,outputData,type,numClusters) specifies the number of clusters to use for the FCM clustering.

    fis = genfis3(inputData,outputData,type,numClusters,options) specifies additional clustering options.


    collapse all

    Create the input and output data.

    Xin = [7*rand(50,1) 20*rand(50,1)-10];
    Xout = 5*rand(50,1);

    Generate a Sugeno-type FIS with 3 clusters.

    opt = NaN(4,1);
    opt(4) = 0;
    fis = genfis3(Xin,Xout,'sugeno',3,opt);

    The fourth input argument specifies the number of clusters. The fifth input argument, opt, specifies the options for the FCM algorithm. The NaN entries of opt specify default option values. Setting opt(4) to 0 turns off the display of iteration information at the command line.

    To see the contents of fis, use showfis(fis).

    Plot the input membership functions.

    [x,mf] = plotmf(fis,'input',1);
    xlabel('Membership Functions for Input 1')
    [x,mf] = plotmf(fis,'input',2);
    xlabel('Membership Functions for Input 2')

    Input Arguments

    collapse all

    Input data, specified as an N-column array, where N is the number of FIS inputs.

    inputData and outputData must have the same number of rows.

    Output data, specified as an M-column array, where M is the number of FIS outputs.

    When using grid partitioning, outputData must have one column. If you specify more than one column for grid partitioning, genfis uses the first column as the output data.

    inputData and outputData must have the same number of rows.

    Fuzzy system type, specified as either 'sugeno' or 'mamdani'.

    Number of FCM clusters, specified as 'auto' or a positive integer.

    The number of clusters determines the number of rules and membership functions in the generated FIS. cluster_n must be an integer or 'auto'. When cluster_n is 'auto', the function uses the subclust algorithm with a cluster range of influence of 0.5 and the minimum and maximum values of inputData and outputData as data scale factors to find the number of clusters. See subclust for more information.

    Clustering options, specified as a vector with the following elements:


    Exponent for the fuzzy partition matrix U, specified as a scalar greater than 1.0. This option controls the amount of fuzzy overlap between clusters, with larger values indicating a greater degree of overlap.

    If your data set is wide with a lot of overlap between potential clusters, then the calculated cluster centers might be very close to each other. In this case, each data point has approximately the same degree of membership in all clusters. To improve your clustering results, decrease this value, which limits the amount of fuzzy overlap during clustering.

    For an example of fuzzy overlap adjustment, see Adjust Fuzzy Overlap in Fuzzy C-Means Clustering.


    Maximum number of iterations, specified as a positive integer.


    Minimum improvement in objective function between two consecutive iterations, specified as a positive scalar.


    Information display flag indicating whether to display the objective function value after each iteration, specified as one of the following:

    • true — Display objective function.

    • false — Do not display objective function.


    If any element of options is NaN, the default value for that option is used.

    The clustering process stops when the maximum number of iterations is reached or when the objective function improvement between two consecutive iterations is less than the specified minimum.

    Output Arguments

    collapse all

    Fuzzy system, returned as a FIS object.

    The input membership function type is 'gaussmf'. By default, the output membership function type is 'linear'. However, if you specify type as 'mamdani', then the output membership function type is 'gaussmf'.

    The following table summarizes the default inference methods.

    Inference MethodDefault
    AND prod

    Version History

    Introduced before R2006a

    expand all

    R2019b: Support for fuzzy inference system structures will be removed

    Support for representing fuzzy inference systems as structures will be removed in a future release. Use mamfis and sugfis objects with this function instead. To convert existing fuzzy inference system structures to objects, use the convertfis function.

    This change was announced in R2018b. Using fuzzy inference system structures with this function issues a warning starting in R2019b.

    See Also

    | | | |