function [pos, E] = bp_chain(n, len) % BP_CHAIN A straight line of n beads along x, from 0 to len. % [pos, E] = bp_chain(n, len) returns positions (n-by-3) and the n-1 % neighbor pairs E. The end beads are 1 and n. x = linspace(0, len, n)'; pos = [x, zeros(n, 2)]; E = [(1:n-1)', (2:n)']; end