⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plot_set.m

📁 FISMAT accommodates different arithmetic operators, fuzzification and defuzzification algorithm, imp
💻 M
字号:
function plot_set(xset,yset)% plot_set(xset,yset)%% Plotting fuzzy sets.% If no matrix yset with membershipvalues is passed, a normal set is % assumed. (ymin = 0 and ymax = 1) % Several setforms are possible: % Vector form - fully overlapping:%   Each element of a 1*n vector describes the center (y=1) of a triangle.%   (n triangles). Only one parameter is passed.%   Each (crisp) input value is connected with two membership values.%   xset should content at least two values. The abscissa-interval is %   restricted to +-1. All values outside this range get the membership 1.% Compact general trapezoidal or matrix form:%   Triangles and trapeziodal forms (open and closed) are possible.%   There are no restrictions for the abscissa range. With a corresponding%   set shape input values outside the interval get the membership 0.%   If input values outside the range should get the membership 1, for the%   most left and right points -inf and +inf respectively should be used.%   xset is a 4*n matrix. The rows 1-4 correspond to the points P1..P4 %   characterising a generel trapezoidal form from left to right. For%   triangles P2 and P3 are equal.%   In comparison to the form described above, dead zones are possible.% Discrete form:%   xset is a vector with the abscissa values.%   yset is a mxn matrix with the n fit values of m subsets in each row.% LR representation:%   The first parameter xset is a matrix that contains the parameters of sets. %   [Xmin;Xmax;m;n;alpha;beta] (or without range: [m;n;alpha;beta]) for each %   set of the library in a row. %   The second parameter defines the shape function L(x)=R(x). %   For trapezoidal shape type 'tr' and "gaussian" shape 'ga' .%   The sets are assumed to be normal. Xmin and Xmax must be the same for all%   sets in the library. See LR_mod.m for more details.%   Left or right open sets are described by alpha or beta equal to inf.%% FSTB - Fuzzy Systems Toolbox for MATLAB% Copyright (c) 1993-1996 by Olaf Wolkenhauer% Control Systems Centre at UMIST% Manchester M60 1QD, UK%%       15-March-1994%       revised 18 Jan 95%	extended to fuzzy numbers in LR representation 13 Nov 95[m,n]=size(xset); m2=[];if nargin==2, [m2,n2]=size(yset); end;if m==1 & nargin==1,                 % Sets nach Siler und Ying 1988.  y=[1;1;0];  x=[xset(1);xset(1);xset(2)];       % Triangle most left.  for i=1:n-2;    x=[x,[xset(i);xset(i+1);xset(i+2)]];    y=[y,[0;1;0]];  end;  x=[x,[xset(n-1);xset(n);xset(n)]]; % Triangle most right.  y=[y,[0;1;1]];  if nargin==2,y=yset;end;  plot(x,y);  axis([xset(1),xset(n),0,1]);  axis('auto');grid on;elseif (m==4 & isempty(m2)) | (m==4 & m2==4),  xmax=xset(4,n); xmin=xset(1,1);  if nargin==1,    y=ones(m,n); y(1,:)=zeros(1,n); y(4,:)=zeros(1,n);    infs=[find(xset==-inf),find(xset==inf)];    if ~isempty(infs),      y(infs)=ones(size(infs));    end;  else    y=yset;  end;  if xmax==inf,  xmax=xset(3,n);xset(4,n)=xset(3,n);end;  if xmin==-inf, xmin=xset(2,1);xset(1,1)=xset(2,1);end;  plot(xset,y);  axis([xmin,xmax,0,1]);  axis;grid on;elseif (m==6 | m==4) & nargin==2 & isstr(yset),		% LR form of a fuzzy set.  LRpar=xset;  % left or right open sets are described by alpha or beta equal to inf :  if ~isempty(find(LRpar==inf)),    LRpar(find(LRpar==inf))=0.000001.*ones(length(find(LRpar==inf)),1);  end;  if (m==4 & n==2),	% find Umin Umax and add on to parameters :    Umax = LRpar(2,n);    Umin = LRpar(1,1);  elseif (n==1),    Umax = LRpar(2)+LRpar(4);    Umin = LRpar(1)-LRpar(3);    % Adding the range to the given matrices of sets:    LRpar = [Umin.*ones(1,n); Umax.*ones(1,n); LRpar];  end;    LRshape=yset;  if strcmp(LRshape,'tr'),    %LRshape = 'max(0,(1-abs(x)))';    LRshape = 'max(0,(1-x))';  elseif strcmp(LRshape,'ga'),    LRshape = 'exp(-x.^2)';  end;   [yset,xset] = LR_mod(LRshape,LRshape,[LRpar(:,1)',0,1],200);  [xset,yset] = stairs(xset,yset);  for i=2:n,	% for each fuzzy set, with parameters in each collumn    [y,x] = LR_mod(LRshape,LRshape,[LRpar(:,i)',0,1],200);    [x,y] = stairs(x,y);    yset = [yset,y];  end;  plot(xset,yset);  axis([xset(1) xset(length(xset)) 0 1.2]);  xlabel('universe of discourse'); ylabel('membership');  grid on; axis;   elseif m==1 & nargin==2,           		% Discrete form.   [xsets,ysets]=stairs(xset,yset(1,:));  for i=2:m2,    [x,y]=stairs(xset,yset(i,:));    ysets=[ysets,y];  end;  plot(xsets,ysets);   % plot(xset,yset);  axis([xset(1) xset(n) 0 1.2]);  xlabel('universe of discourse'); ylabel('membership');  grid on; axis; end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -