September 20, 2017, Wednesday
University of Colorado at Boulder Search A to Z Campus Map University of Colorado at Boulder CU 
Search Links


From MathBio

Jump to: navigation, search


sf.m finds the spring force between two points given a rest length, and the position of the two points. The function returns the force in the x and y directions.

  function Fsp = sf(ba,s,Lrest,kval)        %function that finds the spring force
  %kval = 2.2; %spring constant (N/m)
   %Interesting values (orig 2.2e-7)
   %1e-6, 9e-7
  if ba == s
      Fsp = [0,0];
  m = -kval *abs((sqrt((s(1)- ba(1))^2+(s(2)- ba(2))^2)- Lrest));   %determines magnitude of spring force
  %b= vector position of the bacteria
  %s= vector position of where the spring is attached to the wall
  v = ba-s;   %direction of force
  w = v/sqrt(v(1)^2 + v(2)^2);      %normalizing v
  Fsp = m*w;    %vector force of spring