source: trunk/src/test_tps.m @ 1086

Last change on this file since 1086 was 1071, checked in by g7moreau, 4 years ago
  • Update COPYRIGHT
File size: 1.8 KB
Line 
1%=======================================================================
2% Copyright 2008-2020, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
3%   http://www.legi.grenoble-inp.fr
4%   Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
5%
6%     This file is part of the toolbox UVMAT.
7%
8%     UVMAT is free software; you can redistribute it and/or modify
9%     it under the terms of the GNU General Public License as published
10%     by the Free Software Foundation; either version 2 of the license,
11%     or (at your option) any later version.
12%
13%     UVMAT is distributed in the hope that it will be useful,
14%     but WITHOUT ANY WARRANTY; without even the implied warranty of
15%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16%     GNU General Public License (see LICENSE.txt) for more details.
17%=======================================================================
18
19x=2*pi*rand(100,1);%set of random x coordinates from 0 to 2pi
20y=2*pi*rand(100,1);%set of random y coordinates
21%U=exp(-(x-pi).*(x-pi)-(y-pi).*(y-pi));% gaussian
22U=x;
23[U_smooth,U_tps]=tps_coeff([x y],U,0);%calculate tps coeff
24xI=0:0.1:2*pi;%interpolation grid
25yI=0:0.1:2*pi;
26[XI,YI]=meshgrid(xI,yI);
27[npy,npx]=size(XI);
28XI=reshape(XI,[],1);
29YI=reshape(YI,[],1);
30EM = tps_eval([XI YI],[x y]);%evaluate interpolation on the new grid
31U_eval=EM*U_tps;
32U_eval=reshape(U_eval,npy,npx);
33figure(1)
34imagesc(U_eval,[-1 1])
35[DMX,DMY] = tps_eval_dxy([XI YI],[x y]);
36DUX_eval=DMX*U_tps;
37DUY_eval=DMY*U_tps;
38DUX_eval=reshape(DUX_eval,npy,npx);
39% plot(yI,U_eval(:,5))
40figure(2)
41DUY_eval=reshape(DUY_eval,npy,npx);
42imagesc(DUX_eval,[-1 1])
43% plot(xI,DU_eval(:,5))
44figure(3)
45imagesc(DUY_eval,[-1 1])
46figure(4)
47% plot(x,U_eval(50,:),x,DUX_eval(50,:),x,DUY_eval(50,:))
48size(U_eval(50,:))
49size(xI)
50plot(xI,U_eval(50,:),xI,DUX_eval(50,:),xI,DUY_eval(50,:))
Note: See TracBrowser for help on using the repository browser.