0

I am getting the following error while writing the Matlab code using fuzzy logic toolbox and am unable to resolve it

Error using evalfismex
Illegal parameters in fisTriangleMf() --> a > b
Error in evalfis (line 83)
[output,IRR,ORR,ARR] = evalfismex(input, fis, numofpoints);
Error in Untitl (line 45)
evalfis([1 0.5],fis)

Below is the Matlab code: In the code values 0 1 represent values of cos at 90 degrees and 180 degrees. Basically, I have to plot a graph between EP and different values of cos at different angles. But I am unable to get pass the above mentioned error.

fis = newfis('force');
fis.input(1).name = 'x1';
fis.input(1).range = [0 1];
fis.input(1).mf(1).name = 'NS';
fis.input(1).mf(1).type = 'trimf';
fis.input(1).mf(1).params = [1 0 1];
fis.input(1).mf(2).name = 'NB';
fis.input(1).mf(2).type = 'trimf';
fis.input(1).mf(2).params = [0 1 0];
fis.input(1).mf(3).name = 'Z';
fis.input(1).mf(3).type = 'trimf';
fis.input(1).mf(3).params = [0 1 0];

% input 2
fis.input(2).name = 'x2';
fis.input(2).range = [0 1];
fis.input(2).mf(1).name = 'PS';
fis.input(2).mf(1).type = 'trimf';
fis.input(2).mf(1).params = [0 1 0];
fis.input(2).mf(2).name = 'PB';
fis.input(2).mf(2).type = 'trimf';
fis.input(2).mf(2).params = [1 0 1];

% output
fis.output(1).name = 'EP';
fis.output(1).range = [0 1];
fis.output(1).mf(1).name = 'NME';
fis.output(1).mf(1).type = 'trimf';
fis.output(1).mf(1).params = [1 0];
fis.output(1).mf(2).name = 'NE';
fis.output(1).mf(2).type = 'trimf';
fis.output(1).mf(2).params = [0 1 ];
fis.output(1).mf(3).name = 'ME';
fis.output(1).mf(3).type = 'trimf';
fis.output(1).mf(3).params = [0 1];

% Rules
fis.rule(1).antecedent = [1 1];
fis.rule(1).consequent = 1;
fis.rule(1).weight = 1;
fis.rule(1).connection = 2;
fis.rule(2).antecedent = [2 0];
fis.rule(2).consequent = 2;
fis.rule(2).weight = 1;
fis.rule(2).connection = 1;
fis.rule(3).antecedent = [3 2];
fis.rule(3).consequent = 3;
fis.rule(3).weight = 1;
fis.rule(3).connection = 2;

evalfis([1 0.5],fis)

Any help will really be appreciated.

Wolfie
  • 27,562
  • 7
  • 28
  • 55
hsyeda
  • 3
  • 1

1 Answers1

0

The problem is that you are providing invalid parameters for the triangular membership function. It must take three parameters, say a, b and c, such that a < b < c, where, quoting from MATLAB online documentation,

The parameters a and c locate the “feet” of the triangle and the parameter b locates the peak.

I recommend you use the MATLAB fuzzy GUI to build your system, though. There may be something wrong with your rules.

Diego Stéfano
  • 189
  • 2
  • 5