Changeset 247 for trunk/src/tps_eval_dxy.m
 Timestamp:
 Apr 29, 2011, 6:44:35 PM (13 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/tps_eval_dxy.m
r246 r247 11 11 % N centres, with s=space dimension, DMXY(:,:,k) gives the derivatives 12 12 % along dimension k (=x, y,z) after multiplication by the N+1+s tps sources. 13 function DMXY= tps_eval_dxy(dsites,ctrs)13 function [DMX,DMY] = tps_eval_dxy(dsites,ctrs) 14 14 %% matrix declarations 15 15 [M,s] = size(dsites); [N,s] = size(ctrs); 16 Dsites=zeros(M,N ,s);16 Dsites=zeros(M,N); 17 17 DM = zeros(M,N); 18 DMXY = zeros(M,N+1+s,s);18 % DMXY = zeros(M,N+1+s); 19 19 20 20 %% Accumulate sum of squares of coordinate differences … … 24 24 % Ctrs, consisting of M identical rows (each containing 25 25 % the dth coordinate of the N centers) 26 for d=1:s27 [Dsites(:,:,d),Ctrs] = ndgrid(dsites(:,d),ctrs(:,d));%d coordinates of interpolation points (Dsites) and initial points (Ctrs)28 DM = DM + (Dsites(:,:,d)Ctrs).^2;% add d component squared29 end30 26 31 %% calculate mtrix of tps derivatives 32 DM(DM~=0) = log(DM)+1; %=2 log(r)+1 derivative of the tps r^2 log(r) 33 for d=1:s 34 DMXY(:,1:N,d)=Dsites(:,:,d).*DM; 35 DMXY(:,N+1+d,d)=1;% effect of mean gradient 36 end 27 [Dsites,Ctrs] = ndgrid(dsites(:,1),ctrs(:,1));%d coordinates of interpolation points (Dsites) and initial points (Ctrs) 28 DX=DsitesCtrs; 29 [Dsites,Ctrs] = ndgrid(dsites(:,2),ctrs(:,2));%d coordinates of interpolation points (Dsites) and initial points (Ctrs) 30 DY=DsitesCtrs; 31 DM = DX.*DX + DY.*DY;% add d component squared 32 33 %% calculate matrix of tps derivatives 34 DM(DM~=0) = log(DM(DM~=0))+1; %=2 log(r)+1 derivative of the tps r^2 log(r) 35 36 DMX=[DX.*DM zeros(M,1) ones(M,1) zeros(M,1)];% effect of mean gradient 37 DMY=[DY.*DM zeros(M,1) ones(M,1) zeros(M,1)];% effect of mean gradient 38
Note: See TracChangeset
for help on using the changeset viewer.