1. Open the Fuzzy Control Toolbox, edit the Membership function and fuzzy control rules for the input and output variables, as shown in export as Fuzzy_control.fis file.
2. Open the Simulink module, establish the system diagram shown, two inputs, one output, the processing module is the fuzzy Logic controller with ruleviewer (or fuzzy logic controller).
3. Enter Fuzzy=readfis (' Fuzzy_control ') in the MATLAB window command to load the previously established fuzzy controller into the working space, set the parameters of the Fuzzy control module in Simulink to Fuzzy, save the model, and generate Fuzzy_ Model.mdl.
4.start->matlab->more->systemtest, open the test interface, check main test, menu bar, test Element, Simulink, Select the model Fuzzy_model established in the second step.
5. Variable definition. In Test Vectors, define two test vectors, the variable names are INPUT1 and Input2 respectively, edit the range of two variables, define the test variables in testing Variables, and the variable name is output.
6. Variable mappings. The test vectors input1 and input2 are mapped to the input port in1 and in2 of the fuzzy controller respectively, as input test signals. The output of the test variable is mapped to the Fuzzy controller outlet OUT1. The interface after Setup is shown in the two figure below.
6.Save Results, as shown in.
7. Save and Test.
8. Result format conversion
- System test results are saved in stresults. In Resultsdataset.output, an array of cells for the 169*1 cell (if the output of two variables has a sequence of 13 values). (Note: unit cell is a [n*1 double] structure, indicating that the system has been tested N times.) )
- Under the MATLAB command window, enter Test_data = Stresults. Resultsdataset.output, the test result exists in the variable test_data.
%Import the Blur controller%fuzzy=readfis ('Fuzzy_20150323.fis'); %Run Test%Copy the following code to command window to run Test_data=Stresults. Resultsdataset.output; A=zeros (121,1); forI=1:121b=Test_data{i}; A (i)=b (1); End C=reshape (A, One, One); Table_data=c';%Save to TXT file%d=table_data.*10000; %dlmwrite ('Fuzzy.txt'D'Precision','%.0f','NewLine','PC')
Resources:
- How to use MATLAB to transform fuzzy logic into a query table
- Use of MATLAB fuzzy Toolbox
- Simple Matlab/simulink Fuzzy Controller application Example-figure
- How to transform the fuzzy inference system into a query table (original) under Matlab
- Detailed steps for fuzzy pid Matlab (Simulink) simulation
- The installation method of fuzzy controller under MATLAB
Using MATLAB to generate an offline query table for fuzzy control