top of page

How to use ANFIS Toolbox in MATLAB

How to use ANFIS Toolbox in MATLAB


In today's tutorial, we'll delve into using the ANFIS (Adaptive Neuro-Fuzzy Inference System) toolbox in MATLAB for population prediction. ANFIS combines the merits of neural networks and fuzzy systems to create an adaptive prediction model. We'll use population data from Wikipedia to train an ANFIS model and then test its prediction capabilities.


The ANFIS toolbox integrates neural network algorithms with fuzzy logic systems, allowing for efficient data modeling and prediction. In our example, we'll train an ANFIS model to predict population values based on historical data.

Data Collection

We'll collect population data from Wikipedia, which provides population values for various years. The data will be organized into input-output pairs, with the input representing the year and the output representing the population.

Toolbox Utilization

  1. Data Preparation: We'll format the collected data into a matrix with two columns: one for the year and the other for the corresponding population.

  2. Model Training: The ANFIS model will be trained using the prepared data. We'll utilize grid partitioning to generate initial fuzzy sets and then optimize the model using hybrid optimization techniques.

  3. Model Testing: After training, we'll test the model's prediction accuracy by inputting known years and comparing the predicted population values with the actual values.

Training and Optimization

  1. Parameter Settings: We'll specify the number of input and output membership functions, as well as the optimization method and iteration count.

  2. Training Process: The ANFIS model will undergo training iterations to optimize its parameters and minimize the error between predicted and actual values.

  3. Model Evaluation: We'll monitor the error reduction during training and adjust parameters as needed to improve prediction accuracy.

Testing and Validation

  1. Model Testing: We'll input known years into the trained ANFIS model and observe its predicted population values.

  2. Validation: The predicted values will be compared against actual population data to validate the model's accuracy.


The ANFIS toolbox in MATLAB offers a powerful framework for data modeling and prediction tasks. By combining neural network and fuzzy logic concepts, ANFIS models can effectively capture complex relationships in data and make accurate predictions. In our example, we demonstrated how to use ANFIS for population prediction, showcasing its potential applications in various domains.

3 views0 comments


bottom of page