Plotting Set of Inequalities
이전 댓글 표시
I am working with a set of inequalities:
1) 
2) 
3) 
I can't figure out how to plot it nicely on a 3d graph. The way I have it now, it's all lines, so the actual solutions are not clear.
clear;clc;close all
%{
x_1 = X
x_2 = Y
x_3 = Z
%}
X = [0:1:400];
Y = [0:1:400];
Z = [0:1:400];
% EQ 1A
cond1 = 2.*X;
%EQ 1B
cond2 = 3.*X;
%EQ 2A
xline(150)
%EQ 2B
xline(280)
cond5 = 173 + Y;
cond6 = 20 + Y;
plot3(X,cond1,Z,'DisplayName',"cond1")
hold on
plot3(X,cond2,Z,'DisplayName',"cond2")
hold on
plot3(X,Y,cond5,'DisplayName',"cond5")
hold on
plot3(X,Y,cond6,'DisplayName',"cond6")
hold on
xline(14)
xline(298)
grid on
grid minor
xlabel("x_1")
ylabel("x_2")
zlabel("x_3")
legend
box on
답변 (2개)
It is difficulf for me to interpret what you want to plot.
One way to 'include' an area of inequality in a plot is to use the patch function. I have done this once here to demonstrate the approach, however you will need to make any necessary corrections to my single patch call, and then add your own for the other conditions.
Try something like this --
clear;clc;close all
%{
x_1 = X
x_2 = Y
x_3 = Z
%}
X = [0:1:400];
Y = [0:1:400];
Z = [0:1:400];
% EQ 1A
cond1 = 2.*X;
%EQ 1B
cond2 = 3.*X;
%EQ 2A
xline(150)
%EQ 2B
xline(280)
cond5 = 173 + Y;
cond6 = 20 + Y;
plot3(X,cond1,Z,'DisplayName',"cond1")
patch([X flip(X)], [zeros(size(cond1)) flip(cond1)], [Z flip(Z)], 'r', DisplayName='cond1 inequality region')
hold on
plot3(X,cond2,Z,'DisplayName',"cond2")
hold on
plot3(X,Y,cond5,'DisplayName',"cond5")
hold on
plot3(X,Y,cond6,'DisplayName',"cond6")
hold on
xline(14)
xline(298)
grid on
grid minor
xlabel("x_1")
ylabel("x_2")
zlabel("x_3")
legend
box on
.
Your inequalities can be re-arranged as linear inequalities,
and then plotted using this FEX download,
카테고리
도움말 센터 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



