Im trying to find the distance between 2 points on a truss and I have the length and the x and y of the nodes on the truss but what code in matlab would make this work.

Antworten (1)

KSSV
KSSV am 28 Mär. 2022

1 Stimme

If(x1,y1) and (X2,y2) are two points. To get the distance use the formula:
d = sqtrt((x2-x1)^2+(y2-y1)^2) ;

3 Kommentare

but what if its an array of points
ie
X = [0 0
1 0
2 0
2 1
1 1
0 1
];
that are connected at points
y = [1 2
2 3
3 4
4 5
5 6
6 1
2 4
3 5
1 5
2 6];
KSSV
KSSV am 28 Mär. 2022
d = sqrt((x(:,2)-x(:,1)).^2+(y(:,2)-y(:,1)).^2) ;
VBBV
VBBV am 28 Mär. 2022
+1

Melden Sie sich an, um zu kommentieren.

Kategorien

Produkte

Version

R2022a

Gefragt:

am 28 Mär. 2022

Kommentiert:

am 28 Mär. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by