How can I plot in 2D space the projection of area satisfied by inequalities in 3D space and also colour the area as a colour gradient with respect to the values of the Z variable?

3 ビュー (過去 30 日間)
x+2y+4z > -20 ; x+z < -2.5 ; 2y+3z <-17 ;
I have the above inequalities and I need to plot the area satisfied by these inequalities in 2D space. Then I need to have the area coloured in a gradient which will correspond to the z values. Any idea how to do this? I want a figure similar to the one I have attached. Thanks!

採用された回答

Sam Cook
Sam Cook 2018 年 6 月 13 日
You could create a scatter plot of points that satisfy your equations, and color them based on the Z values.
range = -5:0.02:5;
lr = length(range);
[X, Y, Z] = meshgrid(range, range, range); % Points to check
ineq1 = X + 2*Y + 4*Z > -20; % Define the inequalities
ineq2 = X + Z < -2.5;
ineq3 = 2*Y + 3*Z < -17;
conditions = ineq1 & ineq2 & ineq3;
nX = X(conditions); % Get the points that satisfy them
nY = Y(conditions);
nZ = Z(conditions);
scatter(nX, nY, 10, nZ, 'filled'); % Plot the points, colored according to Z values
colorbar
grid on
Because the equations produce 3D surfaces (rather than lines in 3D space), you

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by