Info

此问题已关闭。 请重新打开它进行编辑或回答。

Problem in handling don't care condition

1 次查看(过去 30 天)
Rahman
Rahman 2012-11-30
关闭: Sabin 2022-12-19
Dear members, I have a problem whose description is:
I have designed a GUI consist of popup menus for "activity, health, diet, sleep, and sentiment". Each popup has a set of values (e.g. diet has 9,18, 27 and the other have also their values). I want to match the users input entered from the GUI with the ruleBase shown below.
ruleBase
activity health diet sleep sentiment ==>recommendation
2 -1 18 -1 -1 ==>100
-1 -1 -1 33 -1 ==>200
-1 5 -1 -1 45 ==>200
4 -1 18 -1 -1 ==>300
-1 15 -1 -1 -1 ==>400
-1 -1 -1 11 45 ==>500
6 -1 -1 -1 30 ==>200
6 -1 -1 -1 30 ==>400
-1 -1 9 -1 15 ==>300
-1 -1 9 -1 15 ==>500
If the user selects activity==2 && diet==18 from the GUI and let the other options to any value then the recommendation generated by the system should be 100. All the rows should be searched for the match and if more then one matches are found then all the recommendations associated with them should be displayed.
I did it like this but have problems listed below:
ruleBase
for i=1:numRows
if activity==2 && diet==18 %for rule 1
health=-1;
sleep=-1;
sentiment=-1;
recommendation=100;
end
if sleep==33 %for rule 2
activity=-1;
health=-1;
diet=-1;
sentiment=-1;
recommendation=200;
end
if health==5 && sentiment==45 %for rule 3
activity=-1;
sleep=-1;
diet=-1;
recommendation=200;
end
if activity==4 && diet==18 %for rule 4
health=-1;
sleep=-1;
sentiment=-1;
recommendation=300;
end
if health==45 %for rule 5
activity=-1;
diet=-1;
sentiment=-1;
sleep=-1;
recommendation=400;
end
if sleep==11 && sentiment==45 %for rule 6
activity=-1;
diet=-1;
health=-1;
recommendation=500;
end
if activity==6 && sentiment==30 %for rule 7
health=-1;
sleep=-1;
diet=-1;
recommendation=200;
end
if activity==6 && sentiment==30 %for rule 8
health=-1;
sleep=-1;
diet=-1;
recommendation=400;
end
if diet==9 && sentiment==15 %for rule 9
health=-1;
sleep=-1;
activity=-1;
recommendation=300;
end
if diet==9 && sentiment==15 %for rule 10
health=-1;
sleep=-1;
activity=-1;
recommendation=500;
end
disp(recommendation);
end
Problems:
1- when i select health=15 then it gives me recommendation=500 which should be 400 in this case. it is because that the conditions for 500 meet before the desired.
Thanking you in anticipation.
Rahman Ali
  1 个评论
Walter Roberson
Walter Roberson 2012-11-30
Which combination with health 15 is giving you 500, and why do you expect it to be 400? Which rule are you expecting to be matched and which rule is being matched instead?

回答(0 个)

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by