close all;
[Z,R] = arcgridread('MtWashington-ft.grd');
mapshow(Z,R,'DisplayType','surface');
title('Original Map')
xlabel('x (easting in meters)'); ylabel('y (northing in meters)')
demcmap(Z);

%1. Trim off data
Z2 = Z(100:end,150:end);

%2. Determine the location of the (1,1)-pixel of the trimmed data. Note
% that in this case, the (1,1)-pixel of Z2 corresponds to the
% (100,150)-pixel of Z.

[x11 y11] = pix2map(R,100,150);

%3. Crete the new map using MAKEREFMAT
R2 = makerefmat(x11,y11,R(1:2,1),R(1:2,2));

figure;
mapshow(Z2,R2,'DisplayType','surface');
title('Truncated Map')
xlabel('x (easting in meters)'); ylabel('y (northing in meters)')
demcmap(Z);
