source: trunk/src/test_tps.m @ 772

Last change on this file since 772 was 434, checked in by sommeria, 13 years ago

corrections in the use of get_field
test_tps introduced, to test thin plate shell functions
tps-eval_dxy corrected (bug on the calculation of the derivatives fixed)

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