📄 untitled.m
字号:
X=-6:0.0001:6;
u1=-2;b1=0.25;u2=2;b2=4;
y1=(1./sqrt(2*pi*b1))*gaussmf(X,[0.5 u1]);
y2=(1./sqrt(2*pi*b2))*gaussmf(X,[2 u2]);
figure(1)
plot(X,y1,X,y2);
P1=0.8*y1./(0.8*y1+0.2*y2);
P2=0.2*y2./(0.8*y1+0.2*y2);
figure(2);
plot(X,P1,X,P2);
[x,y] = ginput(2);
sample=[-3.9847 -3.5549 -1.2401 -0.9780 -0.7932 -2.8531
-2.7605 -3.7287 -3.5414 -2.2692 -3.4549 -3.0752
-3.9934 2.8792 -0.9780 0.7932 1.1882 3.0682
-1.5799 -1.4885 -0.7431 -0.4221 -1.1186 4.2532 ]
a=1;b=1;
for n=1:24
if (sample(n)>=x(1))&&(sample(n)<=x(2))
samplew1(a)=sample(n);
a=a+1;
else
samplew2(b)=sample(n);
b=b+1;
end
end
samplew1,samplew2;
plot(X,P1,X,P2,samplew1,0.5,'co',samplew2,0.5,'ro');
f=[0 4;3 4];
R1=f(1,1)*P1+f(1,2)*P1;
R2=f(2,1)*P2+f(2,2)*P2;
figure(3)
plot(X,R1,X,R2);
[p,q] = ginput(2);
c=1;d=1;
for n=1:24
if (sample(n)>=p(1))&&(sample(n)<=p(2))
sampler1(c)=sample(n);
c=c+1;
else
sampler2(d)=sample(n);
d=d+1;
end
end
plot(X,R1,X,R2,sampler1,2.5,'co',sampler2,2.5,'ro');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -