a)
function center = center_Of_Mass( line ) M = sum(line); radii = 1:1:length(line); center = 1/M*sum(times(radii,line)); end
b)
line = rand (1, 13) *100; center_of_mass ( line )
c)
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