l_sim.m

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

M
80
字号
function res=L_sim(s1,s2)% res=L_sim(s1,s2)%% Similarity between Fuzzy Numbers, sim(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.%% FSTB - Fuzzy Systems Toolbox for MATLAB% Copyright (c) 1993-1996 by Olaf Wolkenhauer% Control Systems Centre at UMIST% Manchester M60 1QD, UK%% O.Wolkenhauer, 7 August 1996% Last change: 7 August 1996 if nargin==0,  %s1 = Trap2L([2.5 3 3 3.5],4);  %s2 = Trap2L([4 4 4 5],4);    s1 = Trap2L([1 2 2 3],4);  s2 = s1;end;nol = size(s1,1);distr = zeros(nol-1,2); % stores the distance measures for left and right for all levels.distc = distr;% Built matrix for the reference s1:% The width of the level below the level considered is taken as 100 percent. Then the% left and right distance of the considered level is calculated in percent.for l=1:nol-1,  distr(l,1) = (s1(l,2)-s1(l+1,2))/(s1(l+1,3)-s1(l+1,2));  distr(l,2) = (s1(l+1,3)-s1(l,3))/(s1(l+1,3)-s1(l+1,2));%  distr(l,1) = (s1(l,2)-s1(l+1,2));%  distr(l,2) = (s1(l+1,3)-s1(l,3));end;% The same for s2 :for l=1:nol-1,  distc(l,1) = (s2(l,2)-s2(l+1,2))/(s2(l+1,3)-s2(l+1,2));  distc(l,2) = (s2(l+1,3)-s2(l,3))/(s2(l+1,3)-s2(l+1,2));%  distc(l,1) = (s2(l,2)-s2(l+1,2));%  distc(l,2) = (s2(l+1,3)-s2(l,3));end;di = abs(distr(:)-distc(:));% Average all the measures:res = mean(di);res = 1-res;if nargin==0 | nargout==0,  x_max=max(s1(nol,3),s2(nol,3));  x_min=min(s1(nol,2),s2(nol,2));  from=x_min-(x_max-x_min)/100*10;  to=x_max+(x_max-x_min)/100*10;  subplot(2,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)]),2));  axis([from to 0 1.2]);grid   ylabel('s1');   subplot(2,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)]),2));  axis([from to 0 1.2]);grid  xlabel(['Shape similarity measure = ',num2str(res)]);end;

⌨️ 快捷键说明

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