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

📄 bls_lip_ts.m

📁 一个用MATLAB编写的优化控制工具箱
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% For training Takagi-Sugeno fuzzy systems using batch least squares%% By: Kevin Passino% Version: 1/26/99%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%clear% First, generate the training data, G% For the M=121 casex=-6:0.1:6;M=length(x)for i=1:M,	z(i)=0.15*(rand-0.5)*2;  % Define the auxiliary variable	G(i)=exp(-50*(x(i)-1)^2)-0.5*exp(-100*(x(i)-1.2)^2)+atan(2*x(i))+2.15+...	0.2*exp(-10*(x(i)+1)^2)-0.25*exp(-20*(x(i)+1.5)^2)+0.1*exp(-10*(x(i)+2)^2)-0.2*exp(-10*(x(i)+3)^2);	if x(i) >= 0		G(i)=G(i)+0.1*(x(i)-2)^2-0.4;	end	Gz(i)=G(i)+z(i); % Adds in the influence of the auxiliary variable%	fpoly(i)=0.6+0.1*x(i);end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Consider the R=20 case% First, form the vector YY=Gz';% Next, find Phi, which involves processing x through phiR=20;c(1,:)=-5.4:0.6:6;sigma(1,:)=0.1*ones(1,R);% Initialize Phi	for j=1:R		mu(j,1)=exp(-0.5*((x(1)-c(1,j))/sigma(1,j))^2);	end		denominator(1)=sum(mu(:,1)); 		for j=1:R		xi(j,1)=mu(j,1)/denominator(1);	endPhi=[xi(:,1)', x(1)*xi(:,1)'];% Form the rest of Phifor i=2:M		for j=1:R		mu(j,i)=exp(-0.5*((x(i)-c(1,j))/sigma(1,j))^2);	end		denominator(i)=sum(mu(:,i)); 		for j=1:R		xi(j,i)=mu(j,i)/denominator(i);	end	Phi=[Phi; xi(:,i)', x(i)*xi(:,i)'];	end% Find the least squares estimatetheta=Phi\Ytheta40=theta;  % This is for saving it for later use in other programssave variables theta40% Note that we tested the result by plotting the resulting approximator% mapping and it produces a reasonable result.  It is for this reason% that we trust the numerical computations, and do not seek to % use other methods for the computation of the estimate.% Next, compute the approximator valuesfor i=1:M,	phi=[xi(:,i)', x(i)*xi(:,i)']';	Fts(i)=theta'*phi;end% Next, plot the basis functions, data and the approximator to comparefigure(1)plot(x,xi,'k')xlabel('x')ylabel('Basis function values')title('Takagi-Sugeno fuzzy system, 20 rules, basis functions')gridfigure(2)plot(x,Gz,'ko',x,Fts,'k')xlabel('x(i)')ylabel('y(i)=G(x(i),z(i)), and fuzzy system output')title('Takagi-Sugeno fuzzy system, 20 rules')gridaxis([min(x) max(x) 0 max(G)])%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Next, consider a different value for sigmaY=Gz';% Next, find Phi, which involves processing x through phiclear Phisigma(1,:)=1*ones(1,R);% Initialize Phi	for j=1:R		mu(j,1)=exp(-0.5*((x(1)-c(1,j))/sigma(1,j))^2);	end		denominator(1)=sum(mu(:,1)); 		for j=1:R		xi(j,1)=mu(j,1)/denominator(1);	endPhi=[xi(:,1)', x(1)*xi(:,1)'];% Form the rest of Phifor i=2:M		for j=1:R		mu(j,i)=exp(-0.5*((x(i)-c(1,j))/sigma(1,j))^2);	end		denominator(i)=sum(mu(:,i)); 		for j=1:R		xi(j,i)=mu(j,i)/denominator(i);	end	Phi=[Phi; xi(:,i)', x(i)*xi(:,i)'];	end% Find the least squares estimatetheta=Phi\Y% Next, compute the approximator valuesfor i=1:M,	phi=[xi(:,i)', x(i)*xi(:,i)']';	Fts(i)=theta'*phi;end% Next, plot the basis functions, data and the approximator to comparefigure(3)plot(x,xi,'k')xlabel('x')ylabel('Basis function values')title('Takagi-Sugeno fuzzy system, 20 rules, basis functions')gridfigure(4)plot(x,Gz,'ko',x,Fts,'k')xlabel('x(i)')ylabel('y(i)=G(x(i),z(i)), and fuzzy system output')title('Takagi-Sugeno fuzzy system, 20 rules')gridaxis([min(x) max(x) 0 max(G)])%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% End of program%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

⌨️ 快捷键说明

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