-## Copyright (C) 2011-2014 L. Markowsky <lmarkov@users.sourceforge.net>
+## Copyright (C) 2011-2018 L. Markowsky <lmarkov@users.sourceforge.net>
## This file is part of the fuzzy-logic-toolkit.
function crisp_x = mom (x, y)
- y_val = @(y_val) if (y_val == max_y) 1 else 0 endif;
+ function y_val = calc_yval(y_val)
+ y_val = @(y_val) calc_yval(y_val);
max_y_locations = arrayfun (y_val, y);
crisp_x = sum (x .* max_y_locations) / sum (max_y_locations);
function crisp_x = som (x, y)
- y_val = @(y_val) if (y_val == max_y) 1 else (NaN) endif;
+ function y_val = calc_yval(y_val)
+ y_val = @(y_val) calc_yval(y_val);
max_y_locations = arrayfun (y_val, y);
crisp_x = min (x .* max_y_locations);
function crisp_x = lom (x, y)
- y_val = @(y_val) if (y_val == max_y) 1 else (NaN) endif;
+ function y_val = calc_yval(y_val)
+ y_val = @(y_val) calc_yval(y_val);
max_y_locations = arrayfun (y_val, y);
crisp_x = max (x .* max_y_locations);