1 | %======================================================================= |
---|

2 | % Copyright 2008-2014, LEGI UMR 5519 / CNRS UJF 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 | |
---|

19 | x=2*pi*rand(100,1);%set of random x coordinates from 0 to 2pi |
---|

20 | y=2*pi*rand(100,1);%set of random y coordinates |
---|

21 | %U=exp(-(x-pi).*(x-pi)-(y-pi).*(y-pi));% gaussian |
---|

22 | U=x; |
---|

23 | [U_smooth,U_tps]=tps_coeff([x y],U,0);%calculate tps coeff |
---|

24 | xI=0:0.1:2*pi;%interpolation grid |
---|

25 | yI=0:0.1:2*pi; |
---|

26 | [XI,YI]=meshgrid(xI,yI); |
---|

27 | [npy,npx]=size(XI); |
---|

28 | XI=reshape(XI,[],1); |
---|

29 | YI=reshape(YI,[],1); |
---|

30 | EM = tps_eval([XI YI],[x y]);%evaluate interpolation on the new grid |
---|

31 | U_eval=EM*U_tps; |
---|

32 | U_eval=reshape(U_eval,npy,npx); |
---|

33 | figure(1) |
---|

34 | imagesc(U_eval,[-1 1]) |
---|

35 | [DMX,DMY] = tps_eval_dxy([XI YI],[x y]); |
---|

36 | DUX_eval=DMX*U_tps; |
---|

37 | DUY_eval=DMY*U_tps; |
---|

38 | DUX_eval=reshape(DUX_eval,npy,npx); |
---|

39 | % plot(yI,U_eval(:,5)) |
---|

40 | figure(2) |
---|

41 | DUY_eval=reshape(DUY_eval,npy,npx); |
---|

42 | imagesc(DUX_eval,[-1 1]) |
---|

43 | % plot(xI,DU_eval(:,5)) |
---|

44 | figure(3) |
---|

45 | imagesc(DUY_eval,[-1 1]) |
---|

46 | figure(4) |
---|

47 | % plot(x,U_eval(50,:),x,DUX_eval(50,:),x,DUY_eval(50,:)) |
---|

48 | size(U_eval(50,:)) |
---|

49 | size(xI) |
---|

50 | plot(xI,U_eval(50,:),xI,DUX_eval(50,:),xI,DUY_eval(50,:)) |
---|