Nonsingleton input - A Fuzzy logic problem

3 Ansichten (letzte 30 Tage)
Emanuel
Emanuel am 5 Dez. 2012
Hi, i'm a new student of Fuzzy theory, and i'm trying to resolve the following Mamdani problem, considering that the input are nonsigleton.
I have 2 inputs: Temperature (low, medium, high) and price (low, medium, high), that are built using Gaussian and triangular functions, respectively:
%temperature
temperature=15:0.1:45;
tlow = gaussmf(temperature, [2.1 15]);%
tmedium = gaussmf(temperature, [2.1 24]);
thigh = gaussmf(temperature, [2.1 36.5]);
%price
price=1:0.1:6;
plow = trimf(price, [-0.3 1 2.4]);
pmedium = trimf(price, [1.7 3 4.3]);
phigh = trimf(price, [3.7 6 8.3]);
The output function of the problem is the soda consumption (low, medium, high), and is a triangular function:
consumption=500:0.1:6000;
clow = trimf(consumption, [-1000 500 2000]);
cmedium = trimf(consumption, [1500 3000 4500]);
chigh = trimf(consumption, [4000 6000 8000]);
Rules:
1) if TEMPERATURE is low and PRICE is low then CONSUMPTION is big;
2) if TEMPERATURE is low and PRICE is medium then CONSUMPTION is medium;
3) if TEMPERATURE is low and PRICE is high then CONSUMPTION is small;
4) if TEMPERATURE is medium and PRICE is low then CONSUMPTION is big;
5) if TEMPERATURE is medium and PRICE is medium then CONSUMPTION is medium;
6) if TEMPERATURE is medium and PRICE is high then CONSUMPTION is small;
7) if TEMPERATURE is high and PRICE is low then CONSUMPTION is big;
8) if TEMPERATURE is high and PRICE is medium then CONSUMPTION is medium;
9) if TEMPERATURE is high and PRICE is high then CONSUMPTION is small.
I know that first it is necessary calculate the firing level, but i don't know how. Somebody can help me with this problem?
  2 Kommentare
Walter Roberson
Walter Roberson am 5 Dez. 2012
price is "loud" ??
Emanuel
Emanuel am 6 Dez. 2012
Bearbeitet: Emanuel am 6 Dez. 2012
price is high. Could you see my program?
% OPERADOR MAMDANI
clear all
clc
close all
%1ª entrada - Temperatura
t=15:0.1:45;
tbaixa = gaussmf(t, [2.1 15]);%gaussiana = A
tmedia = gaussmf(t, [2.1 24]);%gaussiana = A
talta = gaussmf(t, [2.1 36.5]);%gaussiana = A
plot(t,tbaixa,'b')
hold
plot(t,tmedia,'r')
plot(t,talta,'g')
legend('tbaixa','tmedia','talta')
%1ª entrada - F1 - Temperatura
t=18:0.1:48;
tbaixan = gaussmf(t, [2.2 18]);%gaussiana = A
tmedian = gaussmf(t, [2.2 27]);%gaussiana = A
taltan = gaussmf(t, [2.2 39.5]);%gaussiana = A
figure
plot(t,tbaixan,'b')
hold
plot(t,tmedian,'r')
plot(t,taltan,'g')
legend('tbaixa','tmedia','talta')
tfiringb=min(tbaixa,tbaixan);
tfiringb=max(tfiringb);%firing level
tfiringm=min(tmedia,tmedian);
tfiringm=max(tfiringm);%firing level
tfiringa=min(talta,taltan);
tfiringa=max(tfiringa);%firing level
%2ª entrada - Preço
pr=1:0.1:6;
pbaixo = trimf(pr, [-0.3 1 2.4]);%triangular=B
pmedio = trimf(pr, [1.7 3 4.3]);%triangular=B
palto = trimf(pr, [3.7 6 8.3]);%triangular=B
figure
plot(pr,pbaixo,'b')
hold
plot(pr,pmedio,'r')
plot(pr,palto,'g')
legend('pbaixo','pmedio','palto')
%2ª entrada -F2- Preço
pr=0:0.1:5;
pbaixon = trimf(pr, [-0.1 0.8 2]);%
pmedion = trimf(pr, [1.9 3.3 4.7]);%triangular=B
palton = trimf(pr, [3.2 5.6 8]);%triangular=B
figure
plot(pr,pbaixon,'b')
hold
plot(pr,pmedion,'r')
plot(pr,palton,'g')
legend('pbaixo','pmedio','palto')
%Achando o ponto
pfiringb=min(pbaixo,pbaixon);
pfiringb=max(pfiringb);%firing level
pfiringm=min(pmedio,pmedion);
pfiringm=max(pfiringm);%firing level
pfiringa=min(palton,palton);
pfiringa=max(pfiringa);%firing level
%Saída - Consumo
consumo=500:0.1:6000;
cbaixo = trimf(consumo, [-1000 500 2000]);%
cmedio = trimf(consumo, [1500 3000 4500]);%
calto = trimf(consumo, [4000 6000 8000]);%
figure
plot(consumo,cbaixo,'b')
hold
plot(consumo,cmedio,'r')
plot(consumo,calto,'g')
legend('cbaixo','cmedio','calto')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A1=min(tfiringb,pfiringb);%firing level para 1ª regra
con1=combvec(calto,A1);%
con1=min(con1);
plot(con1)
A2=min(tfiringb,pfiringm);%firing level para 2ª regra
con2=combvec(cmedio,A2);
con2=min(con2);
A3=min(tfiringb,pfiringa);%firing level para 3ª regra
con3=combvec(cbaixo,A2);
con3=min(con3);
A4=min(tfiringm,pfiringb);%firing level para 4ª regra
con4=combvec(calto,A4);
con4=min(con4);
A5=min(tfiringm,pfiringm);%firing level para 5ª regra
con5=combvec(cmedio,A5);
con5=min(con5);
A6=min(tfiringm,pfiringa);%firing level para 6ª regra
con6=combvec(cbaixo,A6);
con6=min(con6);
A7=min(tfiringa,pfiringb);%firing level para 7ª regra
con7=combvec(calto,A7);
con7=min(con7);
A8=min(tfiringa,pfiringm);%firing level para 8ª regra
con8=combvec(cmedio,A8);
con8=min(con8);
A9=min(tfiringa,pfiringa);%firing level par 9ª regra
con9=combvec(cbaixo,A9);
con9=min(con9);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Fuzzy Logic in Simulink finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by