if exist('n')~=1 error('need to assign value for n') end if exist('e')~=1 error('need to assign value for e') end if exist('s')~=1 error('need to assign value for s') end % make an example data set [x,y,z] = peaks; pcolor(x,y,z) cax = caxis; colorbar shading flat % sample it at set of user defined points switch opt case 'ginput' [xd,yd] = ginput(n); case 'rand' xd = 6*(rand([n 1])-0.5); yd = 6*(rand([n 1])-0.5); otherwise error('need to choose a method for selecting test data') end hold on plot(xd,yd,'ko') % make some data with errors dd = interp2(x,y,z,xd,yd) + e*randn(size(xd)); scatter(xd,yd,30,dd,'filled') caxis(cax) % map the data with griddata zg = griddata(xd,yd,dd,x,y); % map the data with loess filter % s = 10; zl = loess2dg(xd,yd,dd,x,y,s,'distance'); clf subplot(121) pcolor(x,y,z) hold on cax = caxis;colorbar;shading flat plot(xd,yd,'ko') scatter(xd,yd,30,dd,'filled') caxis(cax) subplot(122) pcolor(x,y,zl) caxis(cax) hold on colorbar;shading flat plot(xd,yd,'ko') scatter(xd,yd,30,dd,'filled') caxis(cax)