1% A simple example of divand in 2 dimensions 2% with observations from an analytical function. 3 4 5% observations 6x = rand(75,1); 7y = rand(75,1); 8f = sin(x*6) .* cos(y*6); 9 10% final grid 11[xi,yi] = ndgrid(linspace(0,1,30)); 12 13% reference field 14fref = sin(xi*6) .* cos(yi*6); 15 16% all points are valid points 17mask = ones(size(xi)); 18 19% this problem has a simple cartesian metric 20% pm is the inverse of the resolution along the 1st dimension 21% pn is the inverse of the resolution along the 2nd dimension 22 23pm = ones(size(xi)) / (xi(2,1)-xi(1,1)); 24pn = ones(size(xi)) / (yi(1,2)-yi(1,1)); 25 26% correlation length 27len = 0.1; 28 29% signal-to-noise ratio 30lambda = 20; 31 32% fi is the interpolated field 33fi = divand(mask,{pm,pn},{xi,yi},{x,y},f,len,lambda); 34 35% plotting of results 36subplot(1,2,1); 37pcolor(xi,yi,fref); 38shading flat,colorbar 39ca = caxis; 40set(findobj(gcf,'FontSize',10),'FontSize',16) 41title('Reference field and observation loc.'); 42hold on 43plot(x,y,'k.'); 44 45subplot(1,2,2); 46hold on 47pcolor(xi,yi,fi); 48shading flat,colorbar 49caxis(ca); 50set(findobj(gcf,'FontSize',10),'FontSize',16) 51title('Interpolated field'); 52 53set(gcf,'PaperUnits','centimeters','PaperPosition',[0 0 25 12 ]); 54print -dpng divand_simple_example.png 55% Copyright (C) 2014 Alexander Barth <a.barth@ulg.ac.be> 56% 57% This program is free software; you can redistribute it and/or modify it under 58% the terms of the GNU General Public License as published by the Free Software 59% Foundation; either version 2 of the License, or (at your option) any later 60% version. 61% 62% This program is distributed in the hope that it will be useful, but WITHOUT 63% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 64% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 65% details. 66% 67% You should have received a copy of the GNU General Public License along with 68% this program; if not, see <http://www.gnu.org/licenses/>. 69