Hi, very new to MATLAB, and im trying to create a loop to calculate the length of bars in a section of a truss. I have the set of coordinates i want to find the distance between. when i 'run it', it returns 34 values instead of the required 17.
Im not sure where im going wrong & is there a more consice/ easier way of achieving this. Also how would i get the L value to return as a [17 x 1] array?
many thanks
%Calculate the length of memebers in truss
%Set of coordinates each Bar spans between.
%B1 = bar 1.
%B1 spans betweeen (0 0 0) & (2000 3232.0508 0)
B1 =[0 0; 2000 3232.0508];B2 =[ 2000 3232.0508; 4500 4098.0762];B3 =[4500 4098.0762; 6000 4617.6915];B4 =[6000 4617.6915; 7500 4098.0762];B5 =[7500 4098.0762; 10000 3232.0508];B6 =[10000 3232.0508;12000 0];B7 =[12000 0;9000 1500 ];B8 =[9000 1500; 6000 1500];B9 =[6000 1500; 3000 1500];B10 =[0 0; 3000 1500];B11 =[ 2000 3232.0508; 3000 1500];B12 =[4500 4098.0762; 3000 1500];B13 =[4500 4098.0762; 6000 1500];B14 =[6000 4617.6915; 6000 1500];B15 =[7500 4098.0762; 6000 1500];B16 =[7500 4098.0762; 9000 1500];B17 =[10000 3232.0508; 9000 1500];%Loop to iterate for every bar in truss
for B = [B1,B2,B3,B4,B5,B6,B7,B8,B9,B10,B11,B12,B13,B14,B15,B16,B17] L = pdist(B,'Euclidean')end
Best Answer