Versions Compared

Key

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

a)

Code Block
function center = center_Of_Mass( line )
M = sum(line);
radii = 1:1:length(line);
center = 1/M*sum(times(radii,line));
end

b)

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

c)

Code Block
function [centerx,centery] = center_Of_Mass2D(mat)
i = 1;
for line = mat
    center(i) = center_Of_Mass ( line );
    i = i+1;
end
centerx = sum(center)/length(center);
center = 0;
i = 1;
for line = mat'
    center(i) = center_Of_Mass ( line );
    i = i+1;
end
centery = sum(center)/length(center);
end