📄 modtrset.m
字号:
function [lib,c,areas] = modtrset(range,no_of_sets)% [lib,c,areas] = modtrset(range,no_of_sets)%% Modeling of trapezoidal fuzzy sets with the mouse.% (Left mouse button picks points)% Each trapecoid is characterised by for points which are picked up with% the mouse FROM LEFT TO RIGHT describing a trapecoid (or triangle).% If the first/fourth point is not near y=0, a to the left/right open % trapecoid is assumed. The points two and third must lie near y=1. (not% exactly-this is done automatically).% If the function is invoked without any parameters, you are ask for the % x-range and number of sets in the library.%% For use with parameters: (no use of the mouse)% Range is a POSITIVE NUMBER !. xfrom=-xto. % no_of_sets = number of sets in the library.%% lib is the library of fuzzy sets in the compact form. 4 characteristic % points describing a general trapecoid - one per collumn.% c is a vector with the local FAM-rule centroids.% areas is a vector with the area of the local FAM-rules.%% FSTB - Fuzzy Systems Toolbox for MATLAB% Copyright (c) 1993-1996 by Olaf Wolkenhauer% Control Systems Centre at UMIST% Manchester M60 1QD, UK%% 20-April-1994if nargin==0, disp('Modeling trapecoidal sets with the mouse :') disp('Left mouse button picks points.') disp('Each trapecoid is characterised by four points from left to right.') xrange(2)=abs(input('Universe of discourse. Domain space X +- : ')); xrange(1)=-1*xrange(2); no_of_sets=input('Number of library subsets in the x-range : ');else xrange(2)=range; xrange(1)=-1*xrange(2);end;clf; axis([xrange(1) xrange(2) 0 1.2]);hold on; grid on% the hole library is stored in a 4 x no_of_sets matrix:lib=zeros(4,no_of_sets); % Each trapezoid in a column with the characteristic points.y=zeros(4,no_of_sets); y(2,:)=ones(1,no_of_sets); y(3,:)=ones(1,no_of_sets);but=1; % button 1=left button.for set=1:no_of_sets, for co=1:4 title(['set no: ',num2str(set),' point no: ',num2str(co)]); [xi,yi,but]=ginput(1); yi=round(yi); plot(xi,yi,'go') lib(co,set)=xi; y(co,set)=yi; end; plot(lib(:,set),y(:,set)); % Determing open trapecoids: if y(1,set)==1, lib(1,set)= -inf, end; if y(4,set)==1, lib(4,set)= inf, end;end;hold off; clf; hold on;plot_set(lib);for co=1:no_of_sets, % determine the local centroids. c(co)=(lib(2,co)+lib(3,co))/2;end;for co=1:no_of_sets, % local area of general trapezoids.areas(co)=0.5*(lib(2,co)-lib(1,co))+(lib(3,co)-lib(2,co))+0.5*(lib(4,co)-lib(3,co));end; xlabel('universe of discourse');ylabel('membership');grid on; hold off;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -