在Matlab中以相同颜色绘制恒定轮廓 [英] Ploting constant contours in the same color in matlab

查看:69
本文介绍了在Matlab中以相同颜色绘制恒定轮廓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[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))‌​;

输出为白页!

推荐答案

删除"您不想要的点:

[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);

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

我还添加了更多点,因为您的网格很小.

I also added more points, as your meshgrid is tiny.

如果使用contourf而不是contour(同样的东西,看上去更好),结果将是这样的:

This is what the result looks like if you use contourf instead of contour (same thing, nicer looking):

这篇关于在Matlab中以相同颜色绘制恒定轮廓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆