## 3 T-S Fuzzy Modelling  
Two main topics of research and application for the development of fuzzy systems, known as Mamdani and Takagi-Sugeno, are highlighted in the bibliography [26]. The If-Then fuzzy rules contain two fundamental parts, which are the premises and the consequents. In this work, we demonstrate a fuzzy algorithm with the T-S fuzzy system, where  
Figure 1: Connection diagram of the power generator system. the premises are extracted with the clustering technique, which consists of grouping the learning data into subsets based on their similarity to each other. Since the fuzzy c-means algorithm was developed for pattern recognition by [16], it has been of great technical value for the fuzzy modelling and control of non-linear dynamic systems, as presented in this work. We use the c-means clustering algorithm to extract the premises or firing degrees of the fuzzy T-S rules, because it is effective and feasible in the search for the best prototypes of the membership values; Equation (1). The iterative fuzzy c-means algorithm is applied to find the clustering centres, \(c_{i}\), which are the prototypes of the membership functions and the membership values, \(\mu_{ik}\in[0,1]\), in the learning phase [27]. \[J(\mathbf{Z};\mathbf{U},\mathbf{C})=\sum_{i=1}^{c}\sum_{k=1}^{N}{(\mu_{ik})^{m} \|z_{k}-c_{i}\|_{I}^{2}}. \tag{1}\]  
where \(N\) is the pairs of input-output data used in order to perform learning, \(c\) is the number of clusters proposed by the expert designer using a certain heuristic rule (in this paper, we set \(c=3\) to illustrate the example of the fuzzy identification, modelling, and control algorithm), \(\mathbf{Z}=\{z_{1},z_{2},\ldots,z_{N}\}\) is the learning matrix, which can be a time series of input-output measurements, \(\mathbf{U}=[\mu_{ik}]\) is the fuzzy partition matrix, with \(i=1,2,\ldots,c\) and \(k=1,2,\ldots,N\), and \(\mathbf{C}=[c_{1},c_{2},\ldots,c_{c}]\) is the vector of centres to identify. Normally, the parameter fuzzy \(m>1\) defines the fuzziness, adjusted heuristically or with some genetic algorithm, and has an important relevance for the representation of the premises in the fuzzy rules. Here, we propose the PSO algorithm to find the best prototypes of the membership functions within the learning space. Several classification and modelling problems in hard sciences and in different topics have been solved efficiently using the fuzzy c-means algorithm and its different variants. In [27], the authors detail the steps to follow in order to implement the c-means algorithm; the Euclidean distances of each sample of the data to be classified from the centres is as follows:  
\[D_{ikI}^{2}=\|z_{k}-c_{i}\|_{I}^{2}={(z_{k}-c_{i})}^{\top}I(z_{k}-c_{i}), \tag{2}\]  
where \(I\) is the identity matrix. In the learning phase, the solution of Equation (1) for the membership functions of each cluster is given by Equations (3) and (4) and is, iteratively:  
\[\mu_{ik}=\frac{1}{\sum_{j=1}^{\top}(\frac{D_{ikI}}{D_{ikI}})^{(2/m-1)}} \tag{3}\]  
\[c_{i}=\frac{\sum_{k=1}^{N}(\mu_{ik})^{m}z_{k}}{\sum_{k=1}^{N}(\mu_{ik})^{m}}, \tag{4}\]  
where \(\mu_{ik}\) is the firing value of the \(i\)-th cluster for the \(k\)-th sample, with \(1\leq i\leq c\), \(1\leq k\leq N\). The construction of the T-S fuzzy model from experimental data was solved in two steps: \((1)\) the structure identification and \((2)\) the estimation of parameters [28]. In step \((1)\), the structure of the model is proposed, using expert knowledge and observations of the response of the system to be modelled. Based on the model structure already defined, the learning matrix is defined for the learning matrix for parameter estimation, using time sequences of the input-output \(X\in\mathbb{R}^{N\times n}\), where \(n\) is the number of state-space variables, as follows,  
\[X= \begin{bmatrix}x_{11}&x_{12}&\cdots&x_{1n}\\ x_{21}&x_{22}&\cdots&x_{2n}\\ \vdots&\vdots&\cdots&\vdots\\ x_{N1}&x_{N2}&\cdots&x_{Nn}\end{bmatrix}