MATLAB Answers

Solving system of inequalities and plot in 3-dimensional

조회 수: 24(최근 30일)
Sultan
Sultan 14 Oct 2019
댓글: John D'Errico 17 Oct 2019
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
plotregion(A,b,lb,ub,[0.1,0.9,0.0]);
axis equal
But I did not get the same plot. Could you please help me in plotting a similar figure.
Thanks in advance.

  댓글 수: 0

Sign in to comment.

채택된 답변

John D'Errico
John D'Errico 14 Oct 2019
편집: John D'Errico 14 Oct 2019
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
And
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 15 Oct 2019
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);
tetramesh(tess,'facecolor','g')
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
Sultan 15 Oct 2019
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 17 Oct 2019
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];
line(Vx(axind),Vy(axind),Vz(axind),'linestyle','-','color','k')
axis equal
view(130,40)
cubeind = [14 14 14 11 12 13 11 12 13;11 12 13 9 10 8 10 8 9];
line(Vx(cubeind),Vy(cubeind),Vz(cubeind),'linestyle',':','color','r')
pyrind = [2 2 2 3 4;3 4 15 15 15]
line(Vx(pyrind),Vy(pyrind),Vz(pyrind),'linestyle','-','color','b')
untitled.jpg
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.

Sign in to comment.

추가 답변(0개)


Translated by