FuzzyLogicToolbox-v2 模糊设计工具.doc_第1页
FuzzyLogicToolbox-v2 模糊设计工具.doc_第2页
FuzzyLogicToolbox-v2 模糊设计工具.doc_第3页
FuzzyLogicToolbox-v2 模糊设计工具.doc_第4页
FuzzyLogicToolbox-v2 模糊设计工具.doc_第5页
已阅读5页,还剩21页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

MatlabUsers GuideForFuzzy Logic ToolboxGUI-Based Fuzzy Inference System (FIS) EditorAuthor: Dr. Adnan Shaout, and Aisha YousufTable of ContentsTable of FiguresiiiList of TablesiiiGUI based fuzzy inference system (FIS) editor2Overview21. FIS Editor32. Membership Function Editor43. Rule Editor64. Surface Viewer85. Rule Viewer9Other useful information12How to save projects12How to open projects12How to integrate a fuzzy controller into Simulink12How to install the toolbox14Examples15Example 1 - Fuzzy Tipper15Step 1: Fuzzifying Inputs15Step 2: Apply Fuzzy (Min/Max or AND/OR) Operator15Step 3: Apply Implication Method16Step 4: Apply Aggregation Method17Step 5: Defuzzify17Example 2 - Fuzzy Grades19Range Selection19Rules21Sample output21References23Table of FiguresFigure 1: Components of the GUI editor2Figure 2: The FIS editor view and functions3Figure 3: The layout and functions of the membership function editor GUI5Figure 4: Rule Editor Layout7Figure 5: Surface Viewer layout8Figure 6: Rule viewer GUI10Figure 7: Interpreting the Fuzzy Inference Diagram11Figure 8: Example of OR method14Figure 9: Fuzzy Tipper Implication method14Figure 10: Fuzzy Tipper Aggregation example15Figure 11: Defuzzified Output16Figure 12: Membership functions of class participation17Figure 13: Membership functions of test average18Figure 14: Final Grade membership functions18Figure 15: Rules for fuzzy grades19Figure 16: Output with no class participation19Figure 17: Output with class participation20List of TablesTable 1: Types of Defuzzification methods available in FIS GUI4Table 2: Membership functions available in Matlab6Table 3: Test average ranges17Table 4: Final grade ranges1823What is a Fuzzy Logic Toolbox?The fuzzy logic toolbox is built in the numeric computing environment of Matlab as a set of functions to create and edit fuzzy inference systems. Stand-alone C programs can also be used to call on the Matlab fuzzy systems. Even with the presence of highly developed graphical user interface (GUI) tools for fuzzy logic toolbox, they can be completely controlled by command line. Fuzzy logic toolbox can be used in the following three ways:1. Using built-in fuzzy graphical interaction tool2. Simulink block3. Command lineAlthough there are many ways of using a fuzzy logic toolbox, this manual is focused on using the fuzzy logic toolbox using the GUI due to its easy to use interface.GUI based fuzzy inference system (FIS) editorFigure 1: Components of the GUI editorOverviewThe FIS editor is made up of five essenstialessential components, as represented in figure 1, and can take as many inputs as a user wants; the only limitation is the memory of the users computer. One concern with this tool is if the system takes incredibly large number of inputs, then it is not practical to use a GUI approach and the simulinkSimulink or the command line would be better. Following are the five componetscomponents to the fuzzy GUI based FIS editor:1. FIS editor2. Membership function editor3. Rule editor4. Surface viewer5. Rule viewerThe FIS editor, rule editor, and membership function editors are the designing tools that are used for designing and editing the system, whereas, the rule viewer and surface viewer display the outputs of the system and are read-only tools. 1. FIS EditorThe FIS editor is the main control for all the GUI tools. Any changes applied to any other GUI editors will be applied to the FIS editor. All the other GUI tools are accessible from this window and new projects can be started here as well. Figure 2: The FIS editor view and functionsTyping in fuzzy at the command prompt in the Matlab command window can open the FIS editor. The FIS editor can be used to create two different types of fuzzy inference systems: Mamdani, and Sugeno. To create new Mamdani or Sugeno system, click on File menu and select the type of system from the New FIS menu. This manual is focus on the Mamdani type systems.Once the new FIS is opened, it can be modified in many different ways. If any new variable needs to be added, click on Edit menu and under Add variable select input or output. Likewise, to delete a variable, select that variable, and under Edit menu select remove selected variable. This can also be achieved by selecting a variable and pressing delete key on the keyboard. To rename a variable, click on the variable and type the new name in the edit field and shown in figure 2. The type of fuzzy defuzzification (see complete list in Table 1), aggregation, implication, or, and and methods can also be modified in the fuzzy FIS editor using simple dropdown menus. The membership editor can be opened from the FIS editor window by selecting Membership Functions from the Edit menu or double clicking any variable as shown in Figure 2. Likewise, the rule editor can be opened by using selecting Rules from the Edit menu or by double clicking system diagram as represented in figure 2. Name of Defuzzification MethodDescription of methodcentroidcentroid of area methodbisectorbisector of area methodmommean of maximum methodsomsmallest of maximum methodlomlargest of maximum methodTable 1: Types of Defuzzification methods available in FIS GUILastly, once the modifications to the system are completed, the outputs of the system can be viewed in two forms: surface, and rules. Both of these read-only GUI windows can be opened from the View menu. 2. Membership Function EditorThe membership function editor is the tool that lets the user edit all of membership functions for the inference system. In this editor, type of membership function can be selected and linguistic categories such as high, low; etc can be added or deleted.When a new system is started from scratch, originally three linguistic values are assigned to each variable with triangular membership functions with possible range of values for that input or output being between 0 and 1.Figure 3: The layout and functions of the membership function editor GUIAll the inputs and outputs of the system are displayed in the upper left side of the membership function editor window as shown in figure 3. To edit a particular input/output click on it. Once the lower left of the GUI will display the variable range, i.e. all the possible values for that variable. The range can be changed by simply typing new numbers in the range field. So for example, if a teacher is grading students with a percent scale on 0-100%, the range should be 0 100. Also, the display range is just how much of the graph the user wants to see. Furthermore, when a variable is selected, the graph window with display the membership functions for that variable. To edit a particular membership function, click on the line of that membership function as represented in figure 3. Once the membership function is selected, the following parameters for that function can be modified:1. Name of the membership function, i.e., a linguistic variable such as high, low, medium, etc. for that input/output. This can be typed in the name field. 2. Secondly, a drop-down menu labeled type lets the user select the type of membership function as shown in Figure 3. To see a list of all available membership function is fuzzy logic toolbox, refer to Table 2. 3. Lastly, once the type of membership function is selected, its parameters can be modified in the Params field or by moving the membership function around. Function NameDescription of the functiondsigmfDifference of two sigmoid membership functions.gauss2mfTwo-sided Gaussian curve membership function.gaussmfGaussian curve membership function.gbellmfGeneralized bell curve membership function.pimfPi-shaped curve membership function.psigmfProduct of two sigmoidal membership functions.smfS-shaped curve membership function.sigmfSigmoid curve membership function.trapmfTrapezoidal membership function.trimfTriangular membership function.zmfZ-shaped curve membership function.Table 2: Membership functions available in MatlabSelecting Add MFs can add more membership functions to a particular variable from the Edit menu. Once the membership function is added, it can be modified using the membership function modification steps described above. Also, the membership functions can be removed once choosing Remove Selected MF from the Edit Menu or pressing delete key selects them.Upon completion of modification of the membership functions, this GUI window should be closed so the user can return to the FIS window. The changes made here are automatically saved to the FIS GUI3. Rule EditorThe rule editor, as suggested by the name, lets the user program the fuzzy if-then rules in fuzzy logic toolbox with a very simple GUI application. Once all the inputs have been named accordingly and their membership functions have been modified, the Rule editor window automatically loads the input names and their linguistic values in this editor. Figure 4: Rule Editor LayoutTo add a new rule, the user simply has to select the linguistic value combination from the input menu and select the corresponding output, and hit the Add rule button. The linguist values of the input and output can be selected by highlighting the values in their respective input/output field as shown in figure 4.If a rule needs to be deleted, highlight that rule in the rules field and click the Delete rule button. Likewise, if the rule needs to be changed, highlight that rule, which will automatically highlight the linguistic parameters of that rule in their respective variable field. Highlight the linguist parameter that needs to be changed and click Change rule. Lastly, as shown in figure 4, a linking option also exists that determines how the rules show be linked. That is, should the rule be if field x is low OR field y is high or if field X is low AND field y is high. 4. Surface ViewerThe surface viewer is a read only GUI that displays the output of the function in graphical formats once the rules and membership functions has been edited. An example of what a surface viewer looks like is shown in figure 5. This, however, has one limitation the plot can only be represented if the output is dependent on one or two inputs since it is impossible to graph in 4-dimensions or higher. If more than two input variables are used, only the first two will be represented in surface viewer. Figure 5: Surface Viewer layoutThe surface viewer has few parameters that show how the surface will be viewed. Under the Options menu, the Plot menu allows the user to choose from eight different display styles for the plot. Also, the Color Map allows the surface to be viewed in four different color schemes. The density of the number of grid points can also be modified using the X-gird and Y-grid field on the GUI as displayed in figure 5. Lastly, the Evaluate function on the GUI automatically re-calculates and plots the function every time the changes are made to it the graph. To make that evaluation process manual, uncheck Always evaluate under the options menu. If the fuzzy system has more than one output, then the surface for each output as a function of inputs can be viewed individually in the surface viewer. Just select output to be viewed from the dropdown menu for the filed labeled Z(Z (output) as represented in figure 5. 5. Rule ViewerThe rule viewer lets a user see, in detail, the behavior of each different rule and its contribution to the output of the system given a set of inputs. With the help of this GUI, a user can easily see the effects of changing input variables to the system. The Rule viewer has one column for each input and each output, whereas, the rows represent all the rules that were inserted in the Rule Editor. The inputs are displayed in yellow, while the outputs are displayed in blue. The last plot in the output column(s), as shown in figure 6, represents the final output of the system after defuzzification. Based on the input combination, and the min/max method selected, the system takes the minimum or maximum of the input values for the output and displayed them in the last column. The output values are then combined for defuzzification and represented in the last plot of the output column. This last plot displays the surface generated as a result of combining the output of each rule and the final answer is represented as a red line on top of the input as shown in figure 6. The value is also displayed on top of the output column. Figure 6: Rule viewer GUITo change the value of the input, enter the values in the input field, or move the red input position indicator line on top on each input as shown in figure 6. To move the graphs in the window, use the up, down, left, and right buttons also displayed in figure 6. Figure 7 is a good resource to learn how to interpret the rule viewer results. This figure assumes that the system has two inputs and one output. When the inputs are applied to the system, they are applied to every if/else rule. Based on the min/max rule (applied in the main FIS editor window), the system takes the minimum or the maximum height of the input values and stores it as an output for that rule. Then all the areas of the rules are assembled together using one of the defuzzification rule and give a final output. Figure 7: Interpreting the Fuzzy Inference DiagramOther useful informationHow to save projectsOne disadvantage of this GUI is that it doesnt have a Save project option in any of its menus. However, the projects can be saved. When the user closes the project, that is, all the windows of the FIS editor are being closed; Matlab asks the user to save changes when the last window is closed. To save the project, click yes when Matlab prompts for saving. When saving the project, the extension .fis should be given to fuzzy inference systems. Matlab automatically assigns this, but the user should check as well just to make sure it is there. Additionally a project can be saved by choosing from any fuzzy project menu File Export To Disk. This will allow you to choose the name and location of the project/changes made.How to open projectsTo start a new project, type the word fuzzy in Matlab command window. To open a saved project with .fis extension, make sure that the Matlab command window is in the same directory as the file is saved in. Then type fuzzy filename (with no extension) at the Matlab prompt. For example, if a file was saved as grades.fis, then to open the file type fuzzy grades at the command prompt. How to integrate a fuzzy controller into Simulink In Simulink go to Library Browser, and select the Fuzzy Logic Toolbox. Select Fuzzy Logic Controller with Rule viewer and drag it into the model where the controller will be implemented. The controller only physically allows for one input and output attachment point. Use a Mux block for models that use 1 input and output. Figure 8: Fuzzy Controller Incorporated Into Simulink Model Click on the Fuzzy controller block and paste the name of the fuzzy project previously created. In order to run the fuzzy controller, the project listed in the FIS matrix field must be loaded into the current Matlab workspace. This can be done by opening the project per the prior section and the selectingFileExportTo Workspace.This will add a parameter with the project name in the workspace. Your project should be visible in the workspace parameter window in Matlab. If this was successful, you should be able to run your completed project in the simulation. The Matlab workspace can be saved for future usage with inclusion of the FIS model. How to install the toolboxTo get information regarding installing the fuzzy logic toolbox, and the minimum requirements, refer to 2 in the References section.ExamplesThis section contains very simple examples for the user to understand fuzzy logic toolbox. Example 1 - Fuzzy TipperThe fuzzy tipper is an example built into all fuzzy logic toolboxes for the user to open and learn from. To open up the example in computer for following along with this example, first make sure that the current directory is the Matlab work folder. Then type fuzzy tipper at the Matlab prompt in command window. Fuzzy tipper is a very simple example, and its application is to calculate the tip for a waiter at the restaurant based on the food quality and the service. Step 1: Fuzzifying InputsTo fuzzify the inputs, the membership functions must be developed. In this example, input service is assigned three membership functions, which are poor, good, and excellent, all of which are Gaussian membership functions. The service is rated on the rate of 0-10, 0 being the worst and 10 being the best; therefore, the range of inputs is 0-10. The food quality is based on two membership functions, rancid and delicious, both of which are trapezoidal. The food is also rated on the scale of 0-10. The output, however, is rated on the scale from 0-30, numbers being percent of tip that should be given. Step 2: Apply Fuzzy (Min/Max or AND/OR) OperatorIn this example, the fuzzy OR method was selected as max, and AND method was selected as min. The OR (max) method was used here for the three if-then rules that the fuzzy system has. This should be obvious when looking at the GUI. Shown in figure 8 is an example of applying the OR operator. Figure 9: Example of OR methodStep 3: Apply Implication MethodThe example uses the implication method min, which me

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论