% MATLAB-DIARY-FILE

% Setting up the Fuzzy Controller for the DEMO Temperatur-Control


% 1. Step:   Define the number an names of input variables
% --------------------------------------------------------
>> in=indef
 
                  FUZZY-DESIGN: Input-Variables
 
 

Number of input-variables 2
 
 
Okay, so you have designed 2 input-variable(s). Let's start now.
 
Please input the name of the input-variable and then the abbreviation of it

1. Name Temperature change

Abbreviation of 1. Variable DT

2. Name Temperature

Abbreviation of 2. Variable T

in =

Temperature change
Temperature




% 2. Step:   Define the Controller Output-Variables
% -------------------------------------------------

>> help outdef

 OUTDEF		[SET]=OUTDEF(INSET)
 		OUTDEF is a tool to design output-variables of a fuzzy-control
 		system.
 		OUTDEF returns a matrix SET, which contains the names of
 		the newly designed fuzzy variables (i.e. the input-, the 
 		output-variables and the abbreviations of them).
 		INSET is a corresponding matrix, which contains the in-
 		put-variables.
 
 		Note: 
 		Only a variable of type SET can be displayed using SHOWSET,
 		and only the function OUTDEF can return such types.
 		
 		See also INDEF, CORRECT.

>> set=outdef(in)
 
FUZZY-DESIGN: Output-Variables
 
 

Number of output-variables 1
 
 
Okay, so you have designed 1 output-variable(s). Let's start now.
 
Please input the name of the output-variable and then the abbreviation of it

1. Name Power change

Abbreviation of 1. Variable DP

set =


Temperature change
Temperature




% 3. Step:   Define the Sets for Input and Outputvariables
%            (Linguistic variables)
% --------------------------------------------------------

>> help makeset

 MAKESET	[setdesc]=MAKESET(set) builds the set-description-matrix
 		'setdesc'. 'setdesc' contains the ranges of the input-fuzzy-
 		variables and the output-fuzzy-variables.
 		'set' must be a fuzzy-set matrix (i.e. of type SET), which is a
 		result of the function OUTDEF.
 
 		See also: OUTDEF, INDEF, EDITSET

>> [sd]=makeset(set)

 Input-Variable 1: Temperature change
Number of sections: 5
working point x0: 0
interval length h/2: 6


 Input-Variable 2: Temperature
Number of sections: 5
working point x0: 0
interval length h/2: 12


 Output-Variable 1: Power change
Number of sections: 5
working point x0: 0
interval length h/2: 120

sd =

     5     0     6     5     0   120
     5     0    12     0     0     0


% 4. Step:   Define the rules
% ---------------------------


>> help designrule

 DESIGNRULE	[rule]=DESIGNRULE(set,setdesc) is a subroutine to design the 
 		rules for a fuzzy-control-system. 'set' is a matrix of type
 		SET and 'setdesc' is the set-description matrix; to obtain
 		those matrices use the MAKESET- and the OUTDEF-command. Matrix
 		'rules' contains all designed rules of the fuzzy-controller
 		and may later be used for evaluation in this system.
 
 		(note: if you have designed your own matrix of type EXSETDESC
 		       it's still possible to use this command to design the
 		       rules; note also, that 'setdesc' must then also be of
 		       type SETDESC and not of type EXTSETDESC)
 
 		See also MAKESET, INDEF, OUTDEF

>> rule=designrule(set,sd)

% enter the rule in the Graphics-Window
add another rule? [y/n] n

% and another, and another , ...
% we defined 9 rules (they are stored in demo/temp_demo.mat




% 5. Step :   Start Simulation
% ----------------------------
>> help f__simul

   [Temp,time]=f__simul(rule,sd,set)
   
   main simulation procedure



>> [temp,time]=f__simul(rule,sd,set);


% and enjoy the marvelous results:
plot (time,temp)
