描述
代码还没有细看,搜的别人的,而且忘了是谁的了哈哈
用matlab看看还行,项目实施还是得用其他语言
copy在这里,以防丢失
代码
clc;
clear;
t=[0:0.01:1].^1.0;
x=0.5*(t.^2).*cos(5*pi*t.^2)+0.5;
y=0.5*(t.^2).*sin(5*pi*t.^2)+0.5;
%构建绘图网格
[X,Y]=meshgrid(0:0.001:1,0:0.001:1);
sigma=0.05;%影响半径
%初始化
Z=zeros(size(X));
Zsum=Z;
%逐个点叠加
for j=1:length(x)
Z=Gauss2D(X,Y,sigma,x(j),y(j));
Zsum=Heatsum(Zsum,Z);
end
%绘图
hold on
pcolor(X,Y,Zsum);shading interp
plot(x,y,'o')
hold off
axis off
function Z=Gauss2D(X,Y,sigma,a,b)
%XY是网格坐标
%sigma是高斯分布的宽度
%ab是中心点坐标
Z=0.5*exp(-((X-a).^2+(Y-b).^2)./sigma.^2);
end
function B=Heatsum(A1,A2)
%两个点之间叠加
B=1-(1-A1).*(1-A2);
end
运行结果