I have been trying to draw a steel space frame in MATLAB. I have the elementnodes and the nodecoordinates. The coding i have used is a follows:
nodeCoordinates=[0 0 0; 0 0 4; 4 0 4; 4 0 0; 0 5 0; 0 5 4; 4 5 4; 4 5 0; ];
elementnodes=elementNodes=[1 5;2 6;3 7; 4 8; 5 6; 6 7; 7 8; 8 5];
xx=nodeCoordinates(:,1);
yy=nodeCoordinates(:,2);
zz=nodeCoordinates(:,3);
plot3(xx,yy,zz,,'k--')
The code should have given a single storey space frame with 4 coulmns. But it gives some random straight lines. What am I doing wrong in the code

 採用された回答

Walter Roberson
Walter Roberson 2019 年 2 月 9 日

1 投票

use patch() with 'Faces' elementnodes and 'Vertices' NodeCoordinates

7 件のコメント

Swagato Das
Swagato Das 2019 年 2 月 9 日
Thank You for the answer. The patch() gives a polygon. But my structure is a 3D space frame. The figure is given below. I need this figure using MATLAB. Thanks in advance.
Fig1.jpg
OMAR elayan
OMAR elayan 2019 年 4 月 17 日
please sir can you give me code for 3d-space frame
Walter Roberson
Walter Roberson 2019 年 4 月 17 日
Using the vertices nodes from the original question:
nodeCoordinates=[0 0 0; 0 0 4; 4 0 4; 4 0 0; 0 5 0; 0 5 4; 4 5 4; 4 5 0; ];
elementNodes = [1 4 3 2; 5 8 7 6; 1 2 6 5; 3 4 8 7; 2 3 7 6; 1 5 8 4];
patch('Faces', elementNodes, 'Vertices', nodeCoordinates)
I took care to arrange all of the faces counter-clockwise to permit proper lighting.
Swagato Das
Swagato Das 2019 年 4 月 17 日
Thank You sir.
Priyanshu Rajak
Priyanshu Rajak 2020 年 11 月 25 日
will writing just this code work or i need to type something else too?
Walter Roberson
Walter Roberson 2020 年 11 月 25 日
nodeCoordinates=[0 0 0; 0 0 4; 4 0 4; 4 0 0; 0 5 0; 0 5 4; 4 5 4; 4 5 0; ];
elementNodes = [1 4 3 2; 5 8 7 6; 1 2 6 5; 3 4 8 7; 2 3 7 6; 1 5 8 4];
patch('Faces', elementNodes, 'Vertices', nodeCoordinates, 'Facecolor', 'none'); view(3)
Priyanshu Rajak
Priyanshu Rajak 2020 年 11 月 26 日
Thank you Sir.

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

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by