l_dist.m

来自「FISMAT accommodates different arithmetic」· M 代码 · 共 72 行

M
72
字号
function res=L_dist(s1,s2)% res=L_dist(s1,s2)%% Fuzzy distance between Fuzzy Numbers, dis(s1,s2), in level-set representation.%% s1 and s2 are fuzzy quantities defined in terms of alpha-cuts (level sets).% The first column of both s1 and s2 define the levels that are required to be% equal. The second and third column define the alpha cut of the associated level.% In consequence only convex fuzzy quantities are allowed.%% If invoked without lefthand arguments a plot is generated. If invoked without% input parameters, an example is created.%% Using the extension principle, the distance |x1-x2| is extended for fuzzy sets.% FSTB - Fuzzy Systems Toolbox for MATLAB% Copyright (c) 1993-1996 by Olaf Wolkenhauer% Control Systems Centre at UMIST% Manchester M60 1QD, UK% 6 August 1996% Last change: 6 August 1996 if nargin==0,  s1 = Trap2L([2.5 3 3 3.5],4);  s2 = Trap2L([2.5 4 4 5],4);    %s1 = Trap2L([1 2 2 3],4);  %s2 = s1;end;nol = size(s1,1);% Substact the two fuzzy quantities:%res = L_sub(s1,s2);% Take the absolute value:%res = L_abs(res);res=s1;for level=1:nol,  res(level,2) = abs(s1(level,2)-s2(level,2));  res(level,3) = abs(s2(level,3)-s1(level,3));end;if nargin==0 | nargout==0,  x_max=max(max(s1(nol,3),s2(nol,3)),res(nol,3));  x_min=min(min(s1(nol,2),s2(nol,2)),res(nol,2));  from=x_min-(x_max-x_min)/100*10;  to=x_max+(x_max-x_min)/100*10;  subplot(3,1,1),plot_Lset(s1,'y');  title('Families of alpha-cuts:');  set(gca,'YTick',sort([s1(:,1);0]));  set(gca,'XTick',chop(sort([s1(:,2);s1(:,3);s2(:,2);s2(:,3);res(:,2);res(:,3)]),2));  axis([from to 0 1.2]);grid   ylabel('s1');   subplot(3,1,2),plot_Lset(s2,'y');  ylabel('s2');  set(gca,'YTick',sort([s1(:,1);0]));  set(gca,'XTick',chop(sort([s1(:,2);s1(:,3);s2(:,2);s2(:,3);res(:,2);res(:,3)]),2));  axis([from to 0 1.2]);grid  subplot(3,1,3),plot_Lset(res,'r');  ylabel('dist(s1, s2)');  set(gca,'YTick',sort([s1(:,1);0]));  set(gca,'XTick',chop(sort([s1(:,2);s1(:,3);s2(:,2);s2(:,3);res(:,2);res(:,3)]),2));  xlabel('Universe of discourse');  axis([from to 0 1.2]);gridend;

⌨️ 快捷键说明

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