📄 modsuset.m
字号:
function [lib,c,areas] = modsuset(dec,range,no_of_sets,p1,p2)% [lib,c,areas] = modsuset(dec,range,no_of_sets,p1,p2)%% Modeling of symetrical and unimodal trapezoidal fuzzy sets with the mouse.% (Left mouse button picks points)% One trapezoid around x=0 is defined by two characteristic points.% The first point lies at x<0 (using the mouse) and y=0. The second point% which has to be defined with the mouse lies at x<0 and y=1. The right (x>0)% part of the triangle and all other library fuzzy sets are plotted auto-% matically. % If the function is invoked without any parameters, you are ask for the % shape of the most positive and negative trapezoids and the x-range.%% For use with parameters: (no use of the mouse)% dec = 'y' or 'n' indicating if open left/right trapecoids or not.% Range is a POSITIVE NUMBER !. xfrom=-xto. % no_of_sets = number of sets in the library.% p1,p2 are the characteristic points.%% 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('Symetrical unimodal fuzzy set library :') disp('Left mouse button picks points.') disp('Pick TWO characteristical points of a trapezoid; left from x=0.') dec=input('Open boundary (open left and right trapezoid) ? y/n [y]: ','s'); if isempty(dec) dec='y'; end; 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 (odd !): ');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 4xno_of_sets matrix:lib=zeros(4,no_of_sets); % Each trapezoid in a collumn 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; mid=ceil(no_of_sets/2); % button 1=left button.if nargin==0, for co=1:2 [xi,yi,but]=ginput(1); yi=round(yi); plot(xi,yi,'go') lib(co,mid)=xi; end; hold off; else lib(1,mid)=p1; lib(2,mid)=p2;end;lib(3,mid)=abs(lib(2,mid)); % complete the half right to x=0.lib(4,mid)=abs(lib(1,mid));dist=xrange(2)/floor(no_of_sets/2); % distance between the midpoints.dis=dist;for co=1:floor(no_of_sets/2), % completing the library sets. lib(2,mid+co)=dis+lib(2,mid); % start with positive x-range. lib(3,mid+co)=dis+lib(3,mid); lib(1,mid+co)=dis+lib(1,mid); lib(4,mid+co)=dis+lib(4,mid); dis=dis+dist;end;for co=1:floor(no_of_sets/2), % negative x-range. lib(:,co)=(fliplr((-1.*lib(:,(no_of_sets+1)-co))'))';end;clf; if dec=='y', % open left/right trapezoids. lib(1,1)=-inf; lib(2,1)=(lib(3,1)+lib(2,1))/2; lib(4,no_of_sets)=inf; lib(3,no_of_sets)=(lib(2,no_of_sets)+lib(3,no_of_sets))/2;end; 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; % Determine the overlap of two adjencent sets. (only for positive overlap% values with sense)% For symetrical unimodal trapezoids only once calculated.alpha=atan(1/(lib(2,mid+1)-lib(1,mid+1)));beta=atan(1/(lib(4,mid)-lib(3,mid)));gamma=pi-alpha-beta; cl=lib(4,mid)-lib(1,mid+1);al=(sin(alpha)*cl)/sin(gamma); bl=(sin(beta)*cl)/sin(gamma);s=(al+bl+cl)/2; o=sqrt(s*(s-al)*(s-bl)*(s-cl)); % Heronic formulaoverlap=['overlap = ',num2str(round(o*100/areas(mid))),'%'];title(overlap);xlabel('universe of discourse');ylabel('membership');grid on; hold off;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -