📄 getfis.m
字号:
if isempty(fis.rule(i).weight)
ermsg = sprintf('weight of rule %d is empty.',i);
error(ermsg);
end
rules(i, numInputs+numOutputs+1)=fis.rule(i).weight;
if isempty(fis.rule(i).connection)
ermsg = sprintf('connection of rule %d is empty.',i);
error(ermsg);
end
rules(i, numInputs+numOutputs+2)=fis.rule(i).connection;
end
out=rules;
end
case 'inputs'
fprintf(' Name = %s\n',fis.name);
fprintf(' NumInputs = %s\n',num2str(numInputs));
fprintf(' InLabels = \n');
if numInputs~=0,
for i=1:length(fis.input)
fprintf(' %s\n',fis.input(i).name);
end
end
out=[];
case 'outputs'
fprintf(' Name = %s\n',fis.name);
fprintf(' NumOutputs = %s\n',num2str(numOutputs));
fprintf(' OutLabels = \n');
if numOutputs~=0,
for i=1:length(fis.output)
fprintf(' %s\n',fis.output(i).name);
end
end
out=[];
otherwise
error(sprintf('There is no FIS system property called ''%s''', propName));
end
case 3,
% ===============================================
% Handle generic inquiries related to VARIABLES
% ===============================================
if strcmp(arg1,'input') | strcmp(arg1,'output'),
varType=lower(arg1);
varIndex=arg2;
numMFs=getfis(fis,varType,varIndex,'NumMFs');
fprintf(' Name = %s\n',getfis(fis,varType,varIndex,'Name'));
fprintf(' NumMFs = %s\n',num2str(numMFs));
fprintf(' MFLabels = \n');
if numMFs~=0,
mfLabels=getfis(fis,varType,varIndex,'MFLabels');
for n=1:numMFs,
fprintf(' %s\n',mfLabels(n,:));
end
end
range=getfis(fis,varType,varIndex,'Range');
fprintf(' Range = %s\n',mat2str(range));
out=[];
end
case 4,
% ===============================================
% Handle specific inquiries related to VARIABLES
% ===============================================
varType=lower(arg1);
varIndex=arg2;
varProp=lower(arg3);
switch varType
case 'input',
if varIndex>numInputs,
error(sprintf('There are only %i input variables.', numInputs));
end
switch varProp
case 'name'
out=fis.input(varIndex).name;
case 'range'
out=fis.input(varIndex).range;
case 'nummfs'
out=length(fis.input(varIndex).mf);
case 'mflabels'
numMFs=length(fis.input(varIndex).mf);
MFList=[];
for n=1:numMFs,
MFList=strvcat(MFList,fis.input(varIndex).mf(n).name);
end
out=MFList;
otherwise
error(sprintf(['Invalid variable properties : ''%s'' \n' ...
'Valid entries are: \n'...
'\tname \n' ...
'\trange \n' ...
'\tnummfs \n'...
'\tmflabels '], varProp));
end
case 'output',
if varIndex>numOutputs,
error(['There are not that many output variables.']);
end
switch varProp
case 'name'
out=fis.output(varIndex).name;
case 'range',
out=fis.output(varIndex).range;
case 'nummfs',
out=length(fis.output(varIndex).mf);
case 'mflabels',
numMFs=length(fis.output(varIndex).mf);
MFList=[];
for n=1:numMFs,
MFList=strvcat(MFList,fis.output(varIndex).mf(n).name);
end
out=MFList;
otherwise
error(sprintf(['Invalid variable property : ''%s'' \n' ...
'Valid properties are: \n'...
'\tname \n' ...
'\trange \n' ...
'\tnummfs \n'...
'\tmflabels '], varProp));
end
otherwise
error(['Variable type must be either "input" or "output"']);
end
case 5,
% ===============================================
% Handle generic inquiries related to MEMBERSHIP FUNCTIONS
% ===============================================
if strcmp(arg1,'input') | strcmp(arg1,'output'),
varType=lower(arg1);
varIndex=arg2;
MFIndex=arg4;
MFLabels=getfis(fis,varType,varIndex,'MFLabels');
fprintf(' Name = %s\n',getfis(fis,varType,varIndex,'MF',MFIndex,'Name'));
fprintf(' Type = %s\n',getfis(fis,varType,varIndex,'MF',MFIndex,'Type'));
params=getfis(fis,varType,varIndex,'MF',MFIndex,'Params');
fprintf(' Params = %s\n',mat2str(params))
out=[];
end
case 6,
% ===============================================
% Handle specific inquiries related to MEMBERSHIP FUNCTIONS
% ===============================================
varType=lower(arg1);
varIndex=arg2;
MFIndex=arg4;
MFProp=lower(arg5);
switch varType
case 'input'
if varIndex>numInputs,
errStr=['There are only ',int2str(length(fis.input)), ...
' input variables'];
error(errStr)
end
if MFIndex>length(fis.input(varIndex).mf),
errStr=['There are only ',int2str(length(fis.input(varIndex).mf)), ...
' MFs associated with that variable'];
error(errStr)
end
switch MFProp
case 'name'
out=fis.input(varIndex).mf(MFIndex).name;
case 'type'
out=fis.input(varIndex).mf(MFIndex).type;
case 'params'
out=fis.input(varIndex).mf(MFIndex).params;
otherwise
error(sprintf(['Invalid Membership Function property : ''%s'' \n' ...
'Valid properties are : \n' ...
'\tname \n' ...
'\ttype \n' ...
'\tparams \n'], MFProp));
end
case 'output'
if varIndex>numOutputs,
errStr=['There are only ',int2str(length(fis.output)), ...
' output variables'];
error(errStr)
end
if MFIndex>length(fis.output(varIndex).mf),
errStr=['There are only ',int2str(length(fis.output(varIndex).mf)), ...
' MFs associated with that variable'];
error(errStr)
end
switch MFProp
case 'name'
out=fis.output(varIndex).mf(MFIndex).name;
case 'type'
out=fis.output(varIndex).mf(MFIndex).type;
case 'params'
out=fis.output(varIndex).mf(MFIndex).params;
otherwise
error(sprintf(['Invalid Membership Function property : ''%s'' \n' ...
'Valid properties are : \n' ...
'\tname \n' ...
'\ttype \n' ...
'\tparams \n'], MFProp));
end
otherwise
error(['Variable type must be either "input" or "output"']);
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -