Error while using fuzzy logic controller in a simulink model

6 views (last 30 days)
Hi,Help please,i use fuzzy logic controller in a simulink model and i build the entire flc from the command line using Fuzzy Logic Toolbox commands.when i try to run my Simulink model, i obtain this error:
MF 'trampf' does not exist!
??? Error using ==> evalfismex
Exiting ...
Error in ==> evalfis at 84
[output,IRR,ORR,ARR] = evalfismex(input, fis, numofpoints);
this is my code:
%FuzzyControlu1
a=newfis('FuzzyControlu1');
a=addvar(a,'input','e(T)',[-510 490]);
a=addmf(a,'input',1,'N','trampf',[-510 -510 -110 -10]);
a=addmf(a,'input',1,'Z','trampf',[-110 -10 190 290]);
a=addmf(a,'input',1,'P','trampf',[190 290 490 490]);
a=addvar(a,'input','deltae(T)',[-20 20]);
a=addmf(a,'input',2,'N','trapmf',[-20 -20 -10 -4]);
a=addmf(a,'input',2,'Z','trapmf',[-5 -1 1 5]);
a=addmf(a,'input',2,'P','trapmf',[4 10 20 20]);
a=addvar(a,'output','RTI',[-0.43 0.57]);
a=addmf(a,'output',1,'Low','trimf',[-0.43 -0.43 -0.13]);
a=addmf(a,'output',1,'Medium','trimf',[-0.2 0 0.2]);
a=addmf(a,'output',1,'High','trimf',[0.1 0.57 0.57]);
ruleLista=[1 1 2 1 1
2 1 2 1 1
3 1 3 1 1
1 2 2 1 1
2 2 2 1 1
3 2 3 1 1
1 3 3 1 1
2 3 3 1 1
3 3 3 1 1
1 1 2 1 1
1 2 2 1 1
1 2 1 0.8 1];
a=addrule(a,ruleLista);
assignin('base','aa',a);
%FuzzyControlu2
b=newfis('FuzzyControlu2');
b=addvar(b,'input','delta(V)',[-35 35]);
b=addmf(b,'input',1,'N','trampf',[-35 -35 -20 -7]);
b=addmf(b,'input',1,'Z','trampf',[-10 -2 2 10]);
b=addmf(b,'input',1,'P','trampf',[7 20 35 35]);
b=addvar(b,'input','e(V)',[-1070 30]);
b=addmf(b,'input',2,'N','trapmf',[-1070 -1070 -870 -190]);
b=addmf(b,'input',2,'Z','trapmf',[-295 -240 -75 -10]);
b=addmf(b,'input',2,'P','trapmf',[-15 24.5 30 30]);
b=addvar(b,'output','PI',[-0.14 0.86]);
b=addmf(b,'output',1,'Low','trapmf',[-0.14 -0.14 -0.1 -0.04]);
b=addmf(b,'output',1,'Medium','trapmf',[-0.1 -0.05 0.05 0.1]);
b=addmf(b,'output',1,'High','trapmf',[0.05 0.476 0.86 0.86]);
ruleListb=[1 1 3 1 1
2 1 3 1 1
3 1 3 1 1
1 2 3 1 1
2 2 3 1 1
3 2 3 1 1
1 3 2 1 1
2 3 2 1 1
3 3 1 1 1
3 3 2 1 1];
b=addrule(b,ruleListb);
assignin('base','bb',b);
sim('HIVPID',[0 500]);
  1 Comment
iman
iman on 25 Jun 2012
excuse me,when i run my simulink,I have another error :
Error in 'HIVPID/Atomic Subsystem/Fuzzy Logic Controller1/FIS S-function' while executing C MEX S-function 'sffis', (mdlStart), at time 0.0.

Sign in to comment.

Accepted Answer

Arkadiy Turevskiy
Arkadiy Turevskiy on 26 Jun 2012
Just like the error says, there is no membership function trampf, but there is a membership function trapmf (trapezoidal membership function).
Fix this typo in your code and everything should work.
HTH,
Arkadiy

More Answers (0)

Categories

Find more on Fuzzy Logic in Simulink in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!