简体   繁体   English

MATLAB 中二维 function 的阴影区域/不等式

[英]Shading regions/inequalities of a 2D function in MATLAB

I've defined my own function with two input arguments (call it z(x,y) say) and managed to produce a contour plot. What I'd like to do now is to shade the region where, for example, z > 5. The main problem is that z is too complicated to be able to deduce the restrictions on x,y myself.我已经定义了我自己的 function 和两个输入 arguments(称其为 z(x,y))并设法生成轮廓 plot。我现在想做的是遮蔽区域,例如 z > 5. 主要问题是 z 太复杂了,无法自己推导出对 x,y 的限制。 Is there any simple way of doing this?有什么简单的方法可以做到这一点吗?

Did you try to use NaN?您是否尝试使用 NaN?

z(condition) = nan;

before calling contour(), where condition can be on any combination of z, x, y, resulting binary matrix, for instance:在调用 contour() 之前,条件可以是 z、x、y 的任意组合,生成的二进制矩阵,例如:

z(abs(z) > x - y) = nan;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM