📄 readrule.m
字号:
%
% Syntax: strRule = readrule(strBaseFile,RuleNr)
%
% Inputs: strBaseFile is the name of the text file containing the rule base.
% Rule number RuleNr is to be read from the rulebase.
%
% Result: strRule is a textstring containing the RuleNr'th fuzzy rule in
% the rule base, e.g. 'IF ISM AND MVL THEN SBH'.
%
% Petur Snaeland, 30.04.1995.
% Revised Hordur Kvaran, 20.10.97
%
function [strRule] = readrule(strBaseFile,RuleNr)
%
% Open the text file containing the appropriate rule base.
%
[hBaseFile,errormessage] = fopen(strBaseFile,'rt+');
if (hBaseFile==-1),
filepath=which(strBaseFile);
if isempty(filepath),
doevent('MainExit');
error(strcat(strBaseFile,' not found in search path.'));
else hBaseFile = fopen(filepath,'rt+');
end;
end;
%
% Read the rules into one continuous string.
%
RuleBase = fscanf(hBaseFile,'%s');
%
% Find and copy rule number RuleNr.
%
Rule = RuleBase((9*(RuleNr-1)+1):(9*(RuleNr-1)+9));
%
% Add 'IF', 'AND' and 'THEN' to make the returned rule more readable.
%
strRule = [ 'IF ' Rule(1:3) ' AND ' Rule(4:6) ' THEN ' Rule(7:9) ];
%
% Close the file and clear the temporary rulebase.
%
fclose(hBaseFile);
clear RuleBase;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -