Fuzzy Logic Toolbox | ![]() ![]() |
Syntax
Description
Using interval arithmetic, C = fuzarith(X, A, B, operator) returns a fuzzy set C
as the result of applying the function represented by the string, operator
, that performs a binary operation on the sampled convex fuzzy sets A
and B.
The elements of A
and B
are derived from convex functions of the sampled universe, X
:
A
, B
, and X
are vectors of the same dimension.
operator
is one of the following strings: 'sum'
, 'sub'
, 'prod'
, and 'div'
.
C
is a column vector with the same length as X
.
Note
Fuzzy addition might generate the message "divide by zero" but this will not affect the correctness of this function.
|
Examples
point_n = 101;% this determines MF's resolution min_x = -20; max_x = 20;% universe is [min_x, max_x] x = linspace(min_x, max_x, point_n)'; A = trapmf(x, [-10 -2 1 3]);% trapezoidal fuzzy set A B = gaussmf(x, [2 5]);% Gaussian fuzzy set B C1 = fuzarith(x, A, B, 'sum'); subplot(2,1,1); plot(x, A, 'b--', x, B, 'm:', x, C1, 'c'); title('fuzzy addition A+B'); C2 = fuzarith(x, A, B, 'sub'); subplot(2,1,2); plot(x, A, 'b--', x, B, 'm:', x, C2, 'c'); title('fuzzy subtraction A-B'); C3 = fuzarith(x, A, B, 'prod');
![]() | findcluster | fuzblock | ![]() |