# Re: help implementing membership function in C...

David Fuess (fuess@llnl.gov)
Tue, 5 Jan 1999 14:39:43 +0100 (MET)

If you are constrained to integer math then you have only 3 meaningful
values (speed = 2, 3, 4) otherwise the membership is 1 for speed <= 0
and membership = 0 for speed >= 5. Sounds like either a collection of
nested IF statements or an array would suit you better.

// Assuming membership on [0, 100]
int array[3] = {75, 50, 25};

if (speed <= 0)
m = 100;
else if (speed >= 5)
m = 0;
else
m = array[speed - 1);

On 24 Nov 1998 05:25:36 GMT, adb1032@fox.tamu.edu (Avery Demetrius
Buffington) wrote:

>
>Hi,
>
>I'm attempting to solve a control problem with fuzzy instead of a PID
>based scheme. I understand most of what I've read but I'm having some
>problems writing the code.
>
>The target will be an HC12 microcontroller.
>
>For example if my membership function looks like:
>
> 1|\
> | \
> | \
> | \
> | \
> | \
> | \
> 0--------5
>
>I can't figure out the math to determine memership for an x value less
>than 5. I know that I can't use floats since the HC12 does not handle
>float values.
>
>From the book I've been reading there is example source code for the
>function:
>
>if (speed >=0 && speed <=0)
> result=100;
>else if (speed >=0 && speed <=5)
> result=100 - (((speed - (0))*200)/10);
>
>In the book it seems like the '100-' part is used for membership functions
>with a negative slope. and the 'speed-(0)' is the speed minus the lower
>bound of the function.
>
>I just can't figure out where the '200' came from.
>
>Any help, or pointers to help would be greatly appreciated...
>
>thanks,
>
>-avery

############################################################################
This message was posted through the fuzzy mailing list.
(1) To subscribe to this mailing list, send a message body of
"SUB FUZZY-MAIL myFirstName mySurname" to listproc@dbai.tuwien.ac.at
(2) To unsubscribe from this mailing list, send a message body of
"UNSUB FUZZY-MAIL" or "UNSUB FUZZY-MAIL yoursubscription@email.address.com"
to listproc@dbai.tuwien.ac.at
(3) To reach the human who maintains the list, send mail to
fuzzy-owner@dbai.tuwien.ac.at
(4) WWW access and other information on Fuzzy Sets and Logic see
http://www.dbai.tuwien.ac.at/ftp/mlowner/fuzzy-mail.info
(5) WWW archive: http://www.dbai.tuwien.ac.at/marchives/fuzzy-mail/index.html