added matlab fuzzy controller

master
Peter Babič 9 years ago
parent ea265f00e8
commit d140129b65
Signed by: peter.babic
GPG Key ID: 4BB075BC1884BA40
  1. 47
      fuzzy-logic/MATLAB/car_brake.fis
  2. 8
      fuzzy-logic/MATLAB/car_brake.m

@ -0,0 +1,47 @@
[System]
Name='car_brake'
Type='mamdani'
Version=2.0
NumInputs=2
NumOutputs=1
NumRules=6
AndMethod='min'
OrMethod='max'
ImpMethod='min'
AggMethod='max'
DefuzzMethod='centroid'
[Input1]
Name='brakeTemp'
Range=[-20 180]
NumMFs=3
MF1='cool':'pimf',[-110 -30 -10 40]
MF2='warm':'pimf',[-10 40 80 170]
MF3='hot':'pimf',[80 170 190 270]
[Input2]
Name='carSpeed'
Range=[0 180]
NumMFs=4
MF1='slow':'trapmf',[-54 -6 5 30]
MF2='optimal':'trapmf',[5 30 50 80]
MF3='fast':'trapmf',[50 80 100 130.446428571429]
MF4='veryFast':'trapmf',[100 130.267857142857 186 234]
[Output1]
Name='brakePressure'
Range=[-20 20]
NumMFs=5
MF1='greatlyDecreased':'trimf',[-30 -20 -5]
MF2='slightlyDecreased':'trimf',[-20 -5 0]
MF3='normal':'trimf',[-5 0 5]
MF4='slightlyIncreased':'trimf',[0 5 20]
MF5='greatlyIncreased':'trimf',[5 20 30]
[Rules]
0 4, 5 (1) : 2
1 3, 4 (0.75) : 2
2 -4, 2 (0.5) : 1
3 -4, 1 (0.5) : 1
-3 1, 4 (0.25) : 1
0 2, 3 (0.1) : 1

@ -0,0 +1,8 @@
disp('Welcome to car brake pressure fuzzy control.');
disp(' ');
temp = input('Please insert brake temperature in °C: ');
speed = input('Please insert car speed in km/h: ');
fis_brake = readfis('car_brake.fis');
press = evalfis([temp speed], fis_brake);
out = sprintf('The brake pressure shoud be adjusted by %2.2f bar.', press);
disp(out);
Loading…
Cancel
Save