云模型实现图形-MATLAB程序

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

一维云模型

程序:

clc

clear

Ex=170;En=5;He=0.5;

n=5000;

for i=1:n

Enn=randn(1)*He+En;

x(i)=randn(1)*Enn+Ex;

y(i)=exp(-(x(i)-Ex)^2/(2*Enn^2)); end

plot(x,y,'.r')

title('5000个男生身高的一维云图') ylabel('确定度');

xlabel('身高值');

axis([150,190,0,1])

grid on

一维:

clear vars;clc;close all;

Ex1=-8; En1=0.7; He1=0.2; n1=200; Ex2=2.2; En2=2; He2=0.5; n2=800; Ex3=18; En3=4; He3=0.7; n3=1500; En1_t = normrnd(En1,He1,n1,1);

data1 = normrnd(Ex1,En1_t,n1,1);

mu1 = exp(-0.5*((data1-Ex1)./En1_t).^2);

En2_t = normrnd(En2,He2,n2,1);

data2 = normrnd(Ex2,En2_t,n2,1);

mu2 = exp(-0.5*((data2-Ex2)./En2_t).^2);

En3_t = normrnd(En3,He3,n3,1);

data3 = normrnd(Ex3,En3_t,n3,1);

mu3 = exp(-0.5*((data3-Ex3)./En3_t).^2);

figure(1);

plot(data1,mu1,'.b',data2,mu2,'*r',data3,mu3,'+k'); axis equal;

二维云模型

程序:

clc

clear

Ex1=170;En1=5;He1=0.5;

Ex2=65;En2=3;He2=0.2;

n=5000;

for i=1:n

Enn1=randn(1)*He1+En1;

x1(i)=randn(1)*Enn1+Ex1;

Enn2=randn(1)*He2+En2;

x2(i)=randn(1)*Enn2+Ex2;

y(i)=exp(-(x1(i)-Ex1)^2/(2*Enn1^2)-(x2(i)-Ex2)^2/(2*Enn2^2)); end

plot3(x1,x2,y,'.r')

title('5000个男生身高体重的二维云图')

axis([148,190,50,80,0,1])

grid on

结果:

多个一维

clear vars;clc;close all;

Ex1=0; En1=0.103; He1=0.013; n1=5000;

Ex2=0.309; En2=0.064; He2=0.008; n2=5000;

Ex3=0.5; En3=0.039; He3=0.005; n3=5000;

Ex4=0.691; En4=0.064; He4=0.008; n4=5000;

Ex5=1; En5=0.103; He5=0.013; n5=5000;

En1_t = normrnd(En1,He1,n1,1);

data1 = normrnd(Ex1,En1_t,n1,1);

mu1 = exp(-0.5*((data1-Ex1)./En1_t).^2);

En2_t = normrnd(En2,He2,n2,1);

data2 = normrnd(Ex2,En2_t,n2,1);

mu2 = exp(-0.5*((data2-Ex2)./En2_t).^2);

En3_t = normrnd(En3,He3,n3,1);

data3 = normrnd(Ex3,En3_t,n3,1);

mu3 = exp(-0.5*((data3-Ex3)./En3_t).^2);

En4_t = normrnd(En4,He4,n4,1);

data4 = normrnd(Ex4,En4_t,n4,1);

mu4 = exp(-0.5*((data4-Ex4)./En4_t).^2);

En5_t = normrnd(En5,He5,n5,1);

data5 = normrnd(Ex5,En5_t,n5,1);

mu5 = exp(-0.5*((data5-Ex5)./En5_t).^2);

figure(1);

plot(data1,mu1,'.r',data2,mu2,'.r',data3,mu3,'.r',data4,mu4,'.r',data5,mu5,'.r' );

title('评价集')

ylabel('隶属度');

axis([-0.4,1.4,0,1])

grid on

一维

Ex=1100;

En=84.926;

He=0.1;

n=1000;

X=zeros(1,n);

Y=zeros(1,n);

X(1:n)=normrnd(En,He,1,n);

for i=1:n

En1=X(1,i);

X(1,i)=normrnd(Ex,En1,1);

Y(1,i)=exp((-(X(1,i)-Ex)^2)/(2*En1^2));

plot(X,Y,'.','MarkerEdgeColor','k','markersize',4); title('强等级','fontsize',16);

grid on;

end

相关文档
最新文档