matlab程序优化figure[x,y,z] = sphere;a=surf(x,y,z);% sphere centered at originhold onfor i=1:32for j=1:32a(i,j)=surf(x+2*j,y,z+2*i,c); % sphere centered at (3,-2,0)set(a(i,j),'EdgeColor','g','FaceColor','g')endendwhitebg('w')daspect([1 1 1])这
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/16 01:39:16
matlab程序优化figure[x,y,z] = sphere;a=surf(x,y,z);% sphere centered at originhold onfor i=1:32for j=1:32a(i,j)=surf(x+2*j,y,z+2*i,c); % sphere centered at (3,-2,0)set(a(i,j),'EdgeColor','g','FaceColor','g')endendwhitebg('w')daspect([1 1 1])这
matlab程序优化
figure
[x,y,z] = sphere;
a=surf(x,y,z);% sphere centered at origin
hold on
for i=1:32
for j=1:32
a(i,j)=surf(x+2*j,y,z+2*i,c);
% sphere centered at (3,-2,0)
set(a(i,j),'EdgeColor','g','FaceColor','g')
end
end
whitebg('w')
daspect([1 1 1])
这个是用来在一个面上画密密麻麻的球体,但是速度过慢了,希望有大神来优化一下这个程序
matlab程序优化figure[x,y,z] = sphere;a=surf(x,y,z);% sphere centered at originhold onfor i=1:32for j=1:32a(i,j)=surf(x+2*j,y,z+2*i,c); % sphere centered at (3,-2,0)set(a(i,j),'EdgeColor','g','FaceColor','g')endendwhitebg('w')daspect([1 1 1])这
把 for 去掉.c++里面 for 运算 非常快捷.但是 matlab里面 for的运算速度会非常慢.你这里还两重for.