MATLAB Answers

Solving system of inequalities and plot in 3-dimensional

20 ビュー (過去 30 日間)
Sultan 2019 年 10 月 14 日
コメント済み: John D'Errico 2019 年 10 月 17 日
Hello everyone,
I would like to solve the following system of inequalities:
and then plotted (by hand) the vertices as shown in the attached figure.
I tried the functions like "plotregion", "con2vert", etc. For example :
A=[0 -1 -1; -1 -1 -1];
b= [-2 -3/2];
lb=[0 0 0];
ub= [1 1 1];
close all
axis equal
But I did not get the same plot. Could you please help me in plotting a similar figure.
Thanks in advance.

  0 件のコメント

サインイン to comment.


John D'Errico
John D'Errico 2019 年 10 月 14 日
編集済み: John D'Errico 2019 年 10 月 14 日
Um, just because you have decided that the solution is what you plotted there, does not make it consistent with the set of inequalities you posed. So you need to tell us what you really wanted to see - the plot that you show, or the solution to the inequalities you actually wrote down.
In fact, I have no idea why you decided that pyramid drawn in your question is correct. In fact, it seimply is not so.
First, consider the pair of inequalities... We have
R1 + R2 + R3 <= 3/2
R2 + R3 <= 2
But as you can see, R2 and R3 are always in the interval [0,1]. So can you see that the second constraint is trivially true ALWAYS? That second constraint essentially does not even enter into the problem.
That leaves the other constraint, that the sum of the three values is no larger than 3/2. I plotted the resulting domain myself, and found that plotregion was indeed exactly correct in what it produces. (Actually, I know what that region does look like, and I know that plotregion got it right, even without redoing the plot using my own software. But I did anyway.)
Perhaps your real question is how can you produce the figure that you actually drew, which is a totally different question, as that would involve a completely different set of inequalities. Not hard to generate them, but I won't bother to do so unless I know there is a reason.

  4 件のコメント

表示 1 件の古いコメント
John D'Errico
John D'Errico 2019 年 10 月 15 日
Not incomplete information, but mis-information.
So your question actually has abolutely nothing to do with the inequalities you show, but you just want to plot a polyhedron that has those 5 corner vertices?
xyz = [1, 0, 0; 0, 1, 0; 0, 0, 1; 1/2,1/2,1/2; 0, 1, 1];
tess = delaunayTriangulation(xyz);
You can rotate the plot around as you please.
Somehow I think there is still some incomplete information. Are you actually trying to recreate the plot you showed? Including dotted lines, etc? If that is your real goal that you have somehow not managed to get across? Then you just have a bunch of lines. Use the function line to plat them. Or you can just use plot.
Sultan 2019 年 10 月 15 日
Thanks John D'Errico. You helped a lot. I would like to recreate the figure. Could you please help me in that too?
John D'Errico
John D'Errico 2019 年 10 月 17 日
I might start with the inner cube. First, see that plotregion can actually do that, but it will use a random face color, and not dotted lines.
plotregion([],[],[0 0 0],[1 1 1]/2)
Simpler might be to just draw the lines themselves.
V = [0 0 0;eye(3);2*eye(3);eye(3)/2;(1-eye(3))/2;ones(1,3)/2;0 1 1];
Vx = V(:,1);
Vy = V(:,2);
Vz = V(:,3);
axind = [1 1 1;5 6 7];
axis equal
cubeind = [14 14 14 11 12 13 11 12 13;11 12 13 9 10 8 10 8 9];
pyrind = [2 2 2 3 4;3 4 15 15 15]
Now use text to add whatever labels you want. I used different colors to distinguish the various lines. I think I missed a couple of lines in there, but you should get the idea.
Could you have done this with plotregion? Yes, surely so. But why bother? Your goal was to create a given figure.

サインイン to comment.

その他の回答 (0 件)

サインイン してこの質問に回答します。

Translated by