| Fuzzy Logic Toolbox™ | ![]() |
Generate Fuzzy Inference System structure from data using FCM clustering
fismat = genfis3(Xin,Xout) fismat = genfis3(Xin,Xout,type) fismat = genfis3(Xin,Xout,type,cluster_n) fismat = genfis3(Xin,Xout,type,cluster_n,fcmoptions)
genfis3 generates a FIS using fuzzy c-means (FCM) clustering by extracting a set of rules that models the data behavior. The function requires separate sets of input and output data as input arguments. When there is only one output, genfis3 may be used to generate an initial FIS for anfis training. The rule extraction method first uses the fcm function to determine the number of rules and membership functions for the antecedents and consequents.
fismat = genfis3(Xin,Xout) generates a Sugeno-type FIS structure (fismat) given input data Xin and output data Xout. The matrices Xin and Xout have one column per FIS input and output, respectively.
fismat = genfis3(Xin,Xout,type) generates a FIS structure of the specified type, where type is either 'mamdani' or 'sugeno'.
fismat = genfis3(Xin,Xout,type,cluster_n) generates a FIS structure of the specified type and allows you to specify the number of clusters (cluster_n) to be generated by FCM. The number of clusters determines the number of rules and membership functions in the generated FIS. cluster_n must be an integer or 'auto', which uses the subclust algorithm with a radii of 0.5 to find the number of clusters.
fismat = genfis3(Xin,Xout,type,cluster_n,fcmoptions) generates a FIS structure of the specified type and number of clusters and uses the specified fcmoptions for the FCM algorithm. If you omit fcmoptions, the default fcm values are used. See fcm for information about these parameters.
The default input membership function type is 'gaussmf' and the default output membership function type is 'linear'.
The following table summarizes the default inference methods.
| Inference Method | Default |
|---|---|
| AND | prod |
| OR | probor |
| Implication | prod |
| Aggregation | sum |
| Defuzzification | wtaver |
The following example uses the genfis3 function with the minimum number of arguments and generates a FIS using default values.
Xin1 = 7*rand(50,1); Xin2 = 20*rand(50,1)-10; Xin = [Xin1 Xin2]; Xout = 5*rand(50,1); fismat = genfis3(Xin,Xout);
showfis(fismat) displays the contents of each field of the structure fismat.
To plot the input membership functions, type
[x,mf] = plotmf(fismat,'input',1);
subplot(2,1,1), plot(x,mf);
xlabel('Membership Functions for input 1');
[x,mf] = plotmf(fismat,'input',2);
subplot(2,1,2), plot(x,mf);
xlabel('Membership Functions for input 2');

The following example generates a Mamdani FIS with 3 clusters.
Xin1 = 7*rand(50,1); Xin2 = 20*rand(50,1)-10; Xin = [Xin1 Xin2]; Xout = 5*rand(50,1); fismat = genfis3(Xin,Xout,'mamdani',3)
The following example specifies the type of FIS, the number of desired clusters and FCM options.
Xin1 = 7*rand(50,1); Xin2 = 20*rand(50,1)-10; Xin = [Xin1 Xin2]; Xout = 5*rand(50,1); fis = genfis3(Xin,Xout,'mamdani',3,[2,100,1e-5,1])
![]() | genfis2 | gensurf | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |