How to plot the equation |x|+|y|+|z|=1 ?

9 ビュー (過去 30 日間)
Jes
Jes 2017 年 1 月 30 日
コメント済み: Walter Roberson 2017 年 1 月 30 日
I have a 3D equation. Can anyone help me to plot this? Thanks

回答 (2 件)

Benjamin Kraus
Benjamin Kraus 2017 年 1 月 30 日
編集済み: Benjamin Kraus 2017 年 1 月 30 日
If you are using MATLAB R2016b you can use the new fimplicit3 command:
fimplicit3(@(x,y,z) abs(x)+abs(y)+abs(z)-1)
You may also be interested in fplot, fplot3, fsurf, fmesh, fcontour, and fimplicit (some of these have been available since R2016a, but fimplicit3 was added in R2016b).
  1 件のコメント
Walter Roberson
Walter Roberson 2017 年 1 月 30 日
Nice solution, Benjamin!

サインインしてコメントする。


John Chilleri
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.
Using the fill3 command, you can reconstruct the shape:
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
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by