Ploting constant contours in the same color in matlab

痴心易碎 提交于 2019-12-13 08:35:09

问题


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

the output is white page!


回答1:


"delete" the points you do not want:

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

Note that I replaced / by ./

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

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



来源:https://stackoverflow.com/questions/44305405/ploting-constant-contours-in-the-same-color-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!