在matlab中绘制相同颜色的恒定轮廓

时间:2017-06-01 10:43:29

标签: matlab matlab-figure

[x,y] = meshgrid(-10:1:10,-10:1:10); 
idx = (x~=0)&(y~=0);     
contour(x(idx)/(x(idx).^2+y(idx).^2).^(3/2),y(idx)/(x(idx).^‌2+y(idx).^2).^(3/2))‌​;

输出是白页!

1 个答案:

答案 0 :(得分:1)

“删除”您不想要的点:

[x,y] = meshgrid(-10:0.1:10,-10:0.1:10);
Idontwantthis = (x.^2+y.^2)<1;
data= x./(x.^2+y.^2).^(3/2)+y./(x.^2+y.^2).^(3/2);
data(Idontwantthis)=NaN;
contourf(data,20);

请注意,我已将/替换为./

我还添加了更多积分,因为你的网格很小。

如果您使用contourf代替contour(同样的事情,更好看),结果就是这样:enter image description here

相关问题