MATLAB Examples

# alt_4_68.m

Filled contour of soil data with custom colormap

```load soil % Reduce the amount of data for faster computation. factor = 5; Easting = Easting(1:factor:end); Northing = Northing(1:factor:end); Resistivity = Resistivity(1:factor:end); % Define colormap to match book. white = [1 1 1]; cyan = [0 1 1]; magenta = [1 0 1]; myMap = [magenta; 0.7*magenta+0.3*white; 0.5*magenta+0.5*white;... 0.4*magenta+0.6*white; 0.2*magenta+0.8*white; white;... 0.2*cyan+0.8*white; 0.4*cyan+0.6*white;... 0.5*cyan+0.5*white; 0.7*cyan+0.3*white; cyan]; % loess surface fit parameters alpha = 0.25; lambda = 2; % Smooth and grid the data. XI = 0.15:0.05:1.41; YI = (0.15:0.05:3.645)'; nx = length(XI); ny = length(YI); newx = repmat(XI,ny,1); newy = repmat(YI,1,nx); newzE = loess2(Easting,Northing,Resistivity,newx,newy,alpha,lambda); % Make filled contour plot. contourLevel = linspace(10,90,9); contourf(newx,newy,newzE,contourLevel); colormap(myMap) shading flat axis('equal') xlabel('East Distance (km)') ylabel('North Distance (km)') title('Soil Resistivity') set(gca,'XTick',[0.2 0.6 1.0 1.4]) hgc = colorbar; % pos = get(hgc,'Position'); % pos(3) = 0.75*pos(3); % pos(4) = 0.48*pos(4); % set(hgc,'Position',pos); axis tight brighten(0.2) ```