How to plot the equation |x|+|y|+|z|=1 ?
이전 댓글 표시
I have a 3D equation. Can anyone help me to plot this? Thanks
답변 (2개)
Benjamin Kraus
2017년 1월 30일
편집: Benjamin Kraus
2017년 1월 30일
댓글 수: 1
Walter Roberson
2017년 1월 30일
Nice solution, Benjamin!
John Chilleri
2017년 1월 30일
편집: John Chilleri
2017년 1월 30일
Hello,
I'm certain there's a better way to do this, such as with surf, but here is a solution.
If you consider the equation, you realize that it's all planes joined by the 6 vertices {(1,0,0),(0,1,0),(0,0,1),(-1,0,0),(0,-1,0),(0,0,-1)}. These 6 vertices 'form' 8 sides.
fill3([1 0 0],[0 1 0],[0 0 1], 'r')
hold on
fill3([1 0 0],[0 1 0],[0 0 -1], 'r')
fill3([1 0 0],[0 -1 0],[0 0 -1], 'r')
fill3([-1 0 0],[0 -1 0],[0 0 -1], 'r')
fill3([-1 0 0],[0 -1 0],[0 0 1], 'r')
fill3([-1 0 0],[0 1 0],[0 0 1], 'r')
fill3([-1 0 0],[0 1 0],[0 0 -1], 'r')
fill3([1 0 0],[0 -1 0],[0 0 1], 'r')
which results in the following image:

(This is just an angle I chose to show.)
Hope this helps!
댓글 수: 1
John Chilleri
2017년 1월 30일
If you are running R2016b, Benjamin Kraus has the smart solution! I'm running R2015b, and I would encourage my solution only if you are running an older release.
카테고리
도움말 센터 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
