Last change
on this file since 319 was
273,
checked in by sommeria, 13 years ago
|
GUI civ renovated with panels
|
File size:
893 bytes
|
Line | |
---|
1 | % EM: MxN matrix whose i,j position contains the Euclidean |
---|
2 | % distance between the i-th data site and j-th center |
---|
3 | function EM = tps_eval(dsites,ctrs) |
---|
4 | [M,s] = size(dsites); [N,s] = size(ctrs); |
---|
5 | EM = zeros(M,N); |
---|
6 | |
---|
7 | % calculate distance matrix: accumulate sum of squares of coordinate differences |
---|
8 | % The ndgrid command produces two MxN matrices: |
---|
9 | % Dsite, consisting of N identical columns (each containing |
---|
10 | % the d-th coordinate of the M data sites) |
---|
11 | % Ctrs, consisting of M identical rows (each containing |
---|
12 | % the d-th coordinate of the N centers) |
---|
13 | for d=1:s |
---|
14 | [Dsites,Ctrs] = ndgrid(dsites(:,d),ctrs(:,d)); |
---|
15 | EM = EM + (Dsites-Ctrs).^2;%EM=square of distance matrices |
---|
16 | end |
---|
17 | |
---|
18 | % calculate tps |
---|
19 | np=find(EM~=0); |
---|
20 | EM(np) = EM(np).*log(EM(np))/2;%= tps formula r^2 log(r) (EM=r^2) |
---|
21 | |
---|
22 | % add linear gradient part: |
---|
23 | EM = [EM ones(M,1) dsites]; |
---|
Note: See
TracBrowser
for help on using the repository browser.