简体   繁体   中英

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. Is there any simple way of doing this?

Did you try to use NaN?

z(condition) = nan;

before calling contour(), where condition can be on any combination of z, x, y, resulting binary matrix, for instance:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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