0

I am trying to write a custom aggregation function to use in matlab. what i have so far is:

function y = choquet(x)
x=sort(x);
m=[1 0.65 0.4];
for i=1
    y(i)=(x(i))*m(i);
end
for i=2:numel(x)
    y(i)=(x(i)-x(i-1))*m(i);
end
end

which appears to follow the guidelines on matlab's website, but it isn't working as a aggregation function in my fis. (it works in the command line with the proper input). what am i doing wrong? (only playing around at this point with x a vector of 3 elements).

pnuts
  • 58,317
  • 11
  • 87
  • 139
  • The reason why is because this function will only work when `x` is a 3 element vector. If you were to specify anything more than 3 elements, your second `for` loop will generate an out of bounds error as `m` is only 3 elements. Should `i = 4` in the iteration, `m` doesn't have a 4th element (or anything beyond that), and so you'll get an out of bounds error. BTW, what is a "fis"? – rayryeng Jul 17 '14 at 01:22
  • an fis file is a Fuzzy Inference System file in Matlab. I am aware that x has to be a 3 element vector, and pretty sure that the input from my fis is one. Unless I am wrong about that, I don't see what I am doing wrong. – user3846006 Jul 17 '14 at 13:55
  • What is the exact error and where does it happen in your code? Can you place debug statements? Can you print out the size of x in your code before the sort function? – rayryeng Jul 17 '14 at 14:05
  • the error is:Warning: Some input values are outside of the specified input range. > In evalfis at 76 In cmthdlg at 205 – user3846006 Jul 17 '14 at 14:25
  • the same error appeared with the sample function given on matlab's website. – user3846006 Jul 17 '14 at 14:25
  • thanks for the suggestion on printing size, it is definitely not just 3 elements. i will have to start from scratch i guess. thanks for your help. – user3846006 Jul 17 '14 at 14:29

0 Answers0