How can I plot a truss using cartesian coordinates with lines connecting specific points
Afficher commentaires plus anciens
Hi, I'm trying to create a plot that uses the below variables. The nodes matrix represents the location and the elements matrix specifies which nodes are connected.
% x and y nodal coordinates
nodes = [ 0.0 , 0.0; 1.5 , 3.3; 3.0 , 2.0; 4.5 , 3.9; 6.0 , 2.0; 7.5 , 3.3; 9.0 , 0.0];
% element connectivity
elems = [ 1.0 , 2.0; 1.0 , 3.0; 2.0 , 3.0; 2.0 , 4.0; 3.0 , 4.0; 3.0 , 5.0; 4.0 , 5.0; 4.0 , 6.0; 5.0 , 6.0; 5.0 , 7.0; 6.0 , 7.0 ];
The code below shows the outcome I want but is tedious and prone to errors as it requires me to plan the path and also backtrack as it is a continuous line.
x = [nodes(2,1) ; nodes(3,1) ; nodes(1,1) ; nodes(2,1) ; nodes(4,1) ; nodes(3,1) ; nodes(5,1) ; nodes(4,1) ; nodes(6,1) ; nodes(5,1) ; nodes(7,1) ; nodes(6,1) ;];
y = [nodes(2,2) ; nodes(3,2) ; nodes(1,2) ; nodes(2,2) ; nodes(4,2) ; nodes(3,2) ; nodes(5,2) ; nodes(4,2) ; nodes(6,2) ; nodes(5,2) ; nodes(7,2) ; nodes(6,2) ;] ;
plot(x,y)
Thanks for any help.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Structural Analysis dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
