source: trunk/src/script_test_tps.m

Last change on this file was 1139, checked in by sommeria, 12 days ago

series/test patch added + some bug corrections

File size: 1014 bytes
Line 
1%% Test of spline thin plate functions
2
3x=2*pi*rand(100,1);%set of random x coordinates from 0 to 2pi
4y=2*pi*rand(100,1);%set of random y coordinates
5%U=exp(-(x-pi).*(x-pi)-(y-pi).*(y-pi));% gaussian
6U=x;
7[U_smooth,U_tps]=tps_coeff([x y],U,0);%calculate tps coeff, no smoothing
8xI=0:0.1:2*pi;%interpolation grid
9yI=0:0.1:2*pi;
10[XI,YI]=meshgrid(xI,yI);
11[npy,npx]=size(XI);
12XI=reshape(XI,[],1);
13YI=reshape(YI,[],1);
14EM = tps_eval([XI YI],[x y]);%evaluate interpolation on the new grid
15U_eval=EM*U_tps;
16U_eval=reshape(U_eval,npy,npx);
17figure(1)
18imagesc(U_eval,[0 6])
19title('U matrix')
20colorbar
21[DMX,DMY] = tps_eval_dxy([XI YI],[x y]);
22DUX_eval=DMX*U_tps;
23DUY_eval=DMY*U_tps;
24DUX_eval=reshape(DUX_eval,npy,npx);
25% plot(yI,U_eval(:,5))
26figure(2)
27DUY_eval=reshape(DUY_eval,npy,npx);
28imagesc(DUX_eval,[-1 1])
29% plot(xI,DU_eval(:,5))
30figure(3)
31imagesc(DUY_eval,[-1 1])
32figure(4)
33% plot(x,U_eval(50,:),x,DUX_eval(50,:),x,DUY_eval(50,:))
34size(U_eval(50,:))
35size(xI)
36plot(xI,U_eval(50,:),xI,DUX_eval(50,:),xI,DUY_eval(50,:))
Note: See TracBrowser for help on using the repository browser.