blob: 705014511162a29993243cbac4913e15583c451b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
% PURPOSE: find c of m of distribution
function [cx,cy,sx,sy] = centerofmass(m);
[sizey sizex] = size(m);
vx = sum(m);
vy = sum(m');
vx = vx.*(vx>0);
vy = vy.*(vy>0);
x = [1:sizex];
y = [1:sizey];
cx = sum(vx.*x)/sum(vx);
cy = sum(vy.*y)/sum(vy);
sx = sqrt(sum(vx.*(abs(x-cx).^2))/sum(vx));
sy = sqrt(sum(vy.*(abs(y-cy).^2))/sum(vy));
|