# trimf

Triangular-shaped membership function

## Syntax

```y = trimf(x,params)
y = trimf(x,[a b c])
```

## Description

The triangular curve is a function of a vector, `x`, and depends on three scalar parameters a, b, and c, as given by

$f\left(x;a,b,c\right)=\left\{\begin{array}{cc}0,& x\le a\\ \frac{x-a}{b-a},& a\le x\le b\\ \frac{c-x}{c-b},& b\le x\le c\\ 0,& c\le x\end{array}\right\}$

or, more compactly, by

$f\left(x;a,b,c\right)=\mathrm{max}\left(\mathrm{min}\left(\frac{x-a}{b-a},\frac{c-x}{c-b}\right),o\right)$

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

## Examples

collapse all

### Triangle-Shaped Membership Function

```x = 0:0.1:10; y = trimf(x,[3 6 8]); plot(x,y) xlabel('trimf, P=[3 6 8]') ylim([-0.05 1.05]) ```