fuzarith

Perform fuzzy arithmetic

Syntax

C = fuzarith(X,A,B,operator)  

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 operator, which 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: 'sum', 'sub', 'prod', and 'div'.

  • The returned fuzzy set C is a column vector with the same length as X.

Note

Fuzzy addition might generate the message "divide by zero" but this does not affect the accuracy of this function.

Examples

collapse all

Specify Gaussian and Trapezoidal membership functions.

N = 101;
minx = -20;
maxx = 20;
x = linspace(minx,maxx,N);

A = trapmf(x,[-10 -2 1 3]);
B = gaussmf(x,[2 5]);

Evaluate the sum, difference, and product of A and B.

Csum = fuzarith(x,A,B,'sum');
Csub = fuzarith(x,A,B,'sub');
Cprod = fuzarith(x,A,B,'prod');

Plot the results.

figure
subplot(3,1,1)
plot(x,A,'b--',x,B,'m:',x,Csum,'c')
title('Fuzzy Addition, A+B')
legend('A','B','A+B')
subplot(3,1,2)
plot(x,A,'b--',x,B,'m:',x,Csub,'c')
title('Fuzzy Subtraction, A-B')
legend('A','B','A-B')
subplot(3,1,3)
plot(x,A,'b--',x,B,'m:',x,Cprod,'c')
title('Fuzzy Product, A*B')
legend('A','B','A*B')

Introduced before R2006a