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

📄 arith.m

📁 a collection of M-files to study concepts in the following areas of Fuzzy-Set-Theory: Fuzzy or Multi
💻 M
字号:
function [B,V]=arith(U1,A1,U2,A2,oper)
%ARITH: Fuzzy Arithmetic, this function returns multiplication, sumation, 
%	subtraction and devision of two fuzzy numbers and non-fuzzy numbers
%	 A1 and A2 over the niverse of U1 and U2 respectively. 
%	
% 			[B,V]=arith(U1,A1,U2,A2,oper)
%
%	The "oper" input is one of the operations; +, -, *, or /. 
%				
%	Example:	U1=[-2:.2:2];
%			A1=bell_1(U1,2,1,1);
%			U2=[-5:.5:5];
%			A2=3;
%			[B,V]=arith(U1,A1,U2,A2,'+')
%			plot(V,B)
%
%	See also UNION, INTERSEC, NOT

% FISMAT: Fuzzy Inference Systems toolbox for MATLAB
% (c) A. Lotfi, Nottingham Trent University (Email: lotfia@marg.ntu.ac.uk)
% 25-6-96
% The program has been tested on MATLAB version 4.1, Sun workstation.


if length(A1) == 1, 
	A1=fzfir(5,U1,0,0,A1);
end

if length(A2) == 1, 
	A2=fzfir(5,U2,0,0,A2);
end
	
r=imply(A1,A2,1);
[UU2,UU1]=meshgrid(U2,U1);

	if oper == '+',
		VV = UU1 + UU2;
	elseif oper == '*',
		VV = UU1 .* UU2;
	elseif oper == '-',
		VV = UU1 - UU2;
	elseif oper == '/',
		VV = UU1 ./ UU2;
	else
		error('No operation !!!')
	end

z=[VV(:),r(:)];[sz1,sortI]=sort(z(:,1));sortz=[sz1,z(sortI,2)];

maxV=max(max(VV));minV=min(min(VV));
lu1=length(U1);lu2=length(U2);
vstep=(maxV-minV) / ((lu1+lu2)/2);
V=[minV:vstep:maxV];
 
for i=1:length(V)
	position = find(sortz(:,1) <= V(i)+vstep/2 & sortz(:,1) >= V(i)-vstep/2);
	B(i) = max(sortz(position,2));
end

⌨️ 快捷键说明

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