con2dis.m

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

M
52
字号
function [Xdom,m,moments,areas] = con2dis(set,Nel)% [Xdom,m,moments,areas] = con2dis(set,Nel)%% Converts compact triangular form (describing a continuous membership-% function) in a discrete vector form.% set is a 4xl matrix with l sets desribed with four characteristical% points in a column.% The universe of discourse is divided in n discrete points.% Xdom is a 1xNel vector with the X domain. (The same for all sets)% M is a lxNel matrix with the fit-value for one set in each row.% The set in the first collumn (left) of the compact form, % corresponds to the first row in the matrix with the discrete sets.% For discrete sets the moment of the membership-function is% sum(X(i)*m(i)) i from 1 to Nel. (= Xdom*m')% moments/areas=row vector with the first element corresponding to the most% "negative" membership-function.%% FSTB - Fuzzy Systems Toolbox for MATLAB% Copyright (c) 1993-1996 by Olaf Wolkenhauer% Control Systems Centre at UMIST% Manchester M60 1QD, UK%%       22-April-1994[p,l]=size(set);if p~=4, error('number of rows must be four - wrong set format!'),end;m=zeros(l,Nel);% finding infs from sets with left/right open trapezoids:xmax=set(4,l); xmin=set(1,1);if xmax==inf, set(4,l)=set(3,l);end;if xmin==-inf,set(1,1)=set(2,1);end;Xdom=linspace(set(1,1),set(4,l),Nel);%sprintf('discretisation interval: %6.3f',x(n)-x(n-1));% Using the function modlrset() for LR-fuzzy sets:for co=1:l,  al=set(2,co)-set(1,co); m1=set(2,co);  be=set(4,co)-set(3,co); m2=set(3,co);  m(co,:)=modlrset('tr','',[Xdom(1),Xdom(Nel),m1,m2,al,be,0,1],Nel);end;% Calculating the moments:moments=zeros(1,l);for co=1:l,  moments(co)=Xdom*m(co,:)';end;% Calculating the areas:areas=zeros(1,l);for co=1:l,  areas(co)=sum(m(co,:));end;

⌨️ 快捷键说明

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