Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

a)

Code Block
function centerequilibrium = center_Of_Mass( line centerOfMass(vector)
MhalfWeight = sum(linevector)/2;
radii = 1:1:length(line);
center = 1/M*sum(times(radii,line % finner vektorens vekt og deler på 2 
countedWeight = 0; 
block = 1;
while countedWeight < halfWeight
    countedWeight = countedWeight + vector(block);
    block = block + 1;
end
equilibrium = block - 1 - ((countedWeight-halfWeight)/vector(block-1));
end

b)

Code Block
line = rand (1, 13) *100;
center_of_mass ( line )

...