Skip to content
MathWorks - Mobile View
  • Sign In to Your MathWorks AccountSign In to Your MathWorks Account
  • Access your MathWorks Account
    • My Account
    • My Community Profile
    • Link License
    • Sign Out
  • Products
  • Solutions
  • Academia
  • Support
  • Community
  • Events
  • Get MATLAB
MathWorks
  • Products
  • Solutions
  • Academia
  • Support
  • Community
  • Events
  • Get MATLAB
  • Sign In to Your MathWorks AccountSign In to Your MathWorks Account
  • Access your MathWorks Account
    • My Account
    • My Community Profile
    • Link License
    • Sign Out

Videos and Webinars

  • MathWorks
  • Videos
  • Videos Home
  • Search
  • Videos Home
  • Search
  • Contact sales
  • Trial software
3:39 Video length is 3:39.
  • Description
  • Full Transcript
  • Related Resources

Fuzzy Logic Controller in Simulink

Integrate a fuzzy logic controller into a Simulink® model.

This video shows how to integrate a fuzzy logic controller into a Simulink model. In this particular model, you want to control water level in the tank modeled is the subsystem. The tank has one pipe for water inflow and another one for water outflow. It can adjust valve controlling the inflow. But the outflow rate depends on the diameter of the outflow pipe, which is constant, and the pressure hardens a tank, which worries is the water level.

Clearly, the system has some very non-linear characteristics. To add the fuzzy logic controller to this module, we open the Simulink library browser. And in the fuzzy logic tool box library, select Fuzzy Logic Controller in this rule viewer block. We add this block into our model and connect it to the rest of the model.

As you can see, the final logic controller has two inputs. The first one is water level error, which is the difference between the set point and measured water level. And the second input is change of rate of the water level. The output of the controller is a calculated valve position for controlling the tank inflow rate.

We open the block dialog and specify the name of the fuzzy inference system. In our case, this is a variable called tank. Let me show you where it is coming from. For this, we go to MATLAB. And here, you see this variable tank in MATLAB workspace. This variable contains the FIS systems that we have designed previously and we want to implement in Simulink.

You can open fuzzy inference system editor and see that our FIS system tank has two inputs and one output, as expected. It can also see the rules that the FIS system implements. In this case, there are five of them. These rules connect two input variables with an output variable.

Now, let's go back to our Simulink model. This subsystem here creates a repeating sequence of steps that point changes to test our controller performance. Let's start the simulation. On the right, we see the animation showing us that we are tracking the set point well. The set point value is shown by this red line.

You can also see that we are tracking well in this plot on the left. Again, the red line is the set point value. And the blue line is actual water level. The bottom part of the plot shows the valve position controller commands. Another windows that opens up when we run the simulation is a rule viewer. It provides a graphical view of the state of fuzzy logic controller.

Each row of plots corresponds to one rule, so five rows for five rules. The first two columns of plots correspond to controller inputs. And the last column corresponds to controller output. The final output of the system, valve position, is depicted by the thick red line and is determined by the centroid rule.

We can now look at how is the level of the water in the tank changes with differing inputs to the fuzzy logic controller. If you pause or stop the simulation, we can interactively change the input values to see how the output is calculated according to the rules that we have.

We can also look at the features we can access from the rule viewer. From the View tab, we can bring up the surface formed by the rules of our controller. We can also access the three fuzzy logic tool box editors, FIS properties editor, membership function editor, and the rules editor. This concludes the demo. 

Related Products

  • Fuzzy Logic Toolbox

Bridging Wireless Communications Design and Testing with MATLAB

Read white paper

Feedback

Featured Product

Fuzzy Logic Toolbox

  • Request Trial
  • Get Pricing

Up Next:

5:05
Getting Started with Fuzzy Logic Toolbox, Part 1

Related Videos:

8:06
Getting Started with Fuzzy Logic Toolbox, Part 2
4:47
Getting Started with Fuzzy Logic Toolbox, Part 3
22:08
Designing Complex Driver Assistance Logic with MATLAB and...
10:00
Using an RC Controller with Arduino and Simulink

View more related videos

MathWorks - Domain Selector

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

  • Switzerland (English)
  • Switzerland (Deutsch)
  • Switzerland (Français)
  • 中国 (简体中文)
  • 中国 (English)

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文Chinese
    • English
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

  • Contact sales
  • Trial software

MathWorks

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Discover…

Explore Products

  • MATLAB
  • Simulink
  • Student Software
  • Hardware Support
  • File Exchange

Try or Buy

  • Downloads
  • Trial Software
  • Contact Sales
  • Pricing and Licensing
  • How to Buy

Learn to Use

  • Documentation
  • Tutorials
  • Examples
  • Videos and Webinars
  • Training

Get Support

  • Installation Help
  • MATLAB Answers
  • Consulting
  • License Center
  • Contact Support

About MathWorks

  • Careers
  • Newsroom
  • Social Mission
  • Customer Stories
  • About MathWorks
  • Select a Web Site United States
  • Trust Center
  • Trademarks
  • Privacy Policy
  • Preventing Piracy
  • Application Status

© 1994-2022 The MathWorks, Inc.

  • Facebook
  • Twitter
  • Instagram
  • YouTube
  • LinkedIn
  • RSS

Join the conversation