Take a table T, where the columns are x and y coordinates, and each row represents a point. The length is calculated from the first two values, i.e (1,2) for each N.
Whenever I run this, it goes through the iteration for length, but it only uses length at j=5 to calculate force.
My question is how do I get the loop to calculate length, put that through the force formula, and then add to the force sum, then repeat for next iteration?
T = [1 2 ; 3 4 ; 5 6 ; 7 8 ; 9 10];
length = sqrt((T(j,1)-T(1,1))^2+(T(j,2)-T(1,2))^2);
force = force + 2.2*((10/length)^3-(10/length)^2);
1 Comment
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/658928-how-do-i-get-a-loop-to-calculate-for-each-value-of-a-formula-not-just-the-last-n-of-the-input-n#comment_1154753
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/658928-how-do-i-get-a-loop-to-calculate-for-each-value-of-a-formula-not-just-the-last-n-of-the-input-n#comment_1154753
Sign in to comment.