how to plot 3d inequalities on matlab

前端 未结 3 1703
情书的邮戳
情书的邮戳 2020-12-19 18:19

I want to plot a 3d region in MATLAB bounded from a set of inequalities.

For example:

0 <= x <= 1

sqrt(x) <= y <= 1

0 <= z <= 1          


        
3条回答
  •  隐瞒了意图╮
    2020-12-19 18:45

    I've been trying to figure out the same thing, and the trick is to make the size of everything not in the intersection 0. Tobold's scatter3 line uses '3' as the option for size, meaning all points will show up as point 3. This can be substituted for a matrix of equal size to X1 with the set of sizes. The easiest way to do this is just make s = 3*all:

    all = ineq1 & ineq2 & ineq3;
    colors = zeros(size(X))+all;
    sizes = 3 * all;
    scatter3(X1(:),Y1(:),Z1(:),sizes,colors(:)','filled')
    

    That should get you just the area in the intersection.

    -- edit: The color variable needs to change too. You just want the intersection, not the other inequalities.

提交回复
热议问题