%%%%%%%%%%%%%%%%%%%%%%%%%%% %class01.m % %matlab exercises for first class % %PY 341, spring 2012 % %Greg Gerbi %January, 2012 %%%%%%%%%%%%%%%%%%%%%%%%%%% set(0,'defaultaxescolororder',[0 0 0 ; 0 0 1 ; 1 0 0 ; 0 0.75 0.75 ; 0.75 0.75 0]); set(0,'defaultlinemarkersize',10); set(0,'defaultaxesfontsize',14); load NYB %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Make four different kinds of plots of the bathymetry figure(1) clf colormap jet subplot(2,2,1) surf(lon,lat,bathymetry) shading flat xlabel('longitude (degrees)') ylabel('latitude (degrees)') title('Bathymetry (m)') colorbar subplot(2,2,2) pcolor(lon,lat,bathymetry) shading flat xlabel('longitude (degrees)') ylabel('latitude (degrees)') title('Bathymetry (m)') colorbar amerc subplot(2,2,3) contour(lon,lat,bathymetry,[-80:10:0],'k') shading flat xlabel('longitude (degrees)') ylabel('latitude (degrees)') title('Bathymetry (m)') colorbar amerc subplot(2,2,4) contourf(lon,lat,bathymetry) xlabel('longitude (degrees)') ylabel('latitude (degrees)') title('Bathymetry (m)') colorbar amerc %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Make a filled contour plot with a black and white colormap figure(2) len = 100; colors = repmat((0:1./(len-1):1).',[1,3]); colormap(colors) pcolor(lon,lat,bathymetry) shading flat xlabel('longitude (degrees)') ylabel('latitude (degrees)') title('Bathymetry (m)') colorbar amerc %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Plot the bathymetry on ~EW lines every 0.2 degree latmin = lat(1,1); spacing = 0.2; clear x for jn = 1:5 %The upper limit is hardcoded here. Can it be made a variable? latline = latmin + spacing*jn; x(jn,1) = min(find(lat(:,1) > latline)); %Why use column 1 here? end figure(3) plot(lon(x,:).',bathymetry(x,:).') %note the transpose here str1 = ['lat = ',num2str(lat(x(1),1)),'^\circ']; str2 = ['lat = ',num2str(lat(x(2),1)),'^\circ']; str3 = ['lat = ',num2str(lat(x(3),1)),'^\circ']; str4 = ['lat = ',num2str(lat(x(4),1)),'^\circ']; str5 = ['lat = ',num2str(lat(x(5),1)),'^\circ']; legend(str1,str2,str3,str4,str5) %Overlay lines on the map where these profiles cover figure(2) hold on plot(lon(x,:).',lat(x,:).') xlabel('longitude (degrees)') ylabel('Bathymetry (m)') title('Bathymetry along lines of approximately constant latitude (m)') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Make a single vector for all bathymetry data bathyvector = bathymetry(:); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Assignments %Write a comment for every line here %plot bathymetry along lines of longitude spaced every 0.2 degrees %You'll probably want the vectorized bathymetry data (not the gridded data) for much of the % rest of this %Find mean depth of all points on map %Find mean depth of all points IN THE WATER (compute two values--one using algebra % and one using the mean command) %Find median depth of all points IN THE WATER (use the sort command, again two % values--one "by hand" and using the median command) %Find minimum depth of this bathymetry data %Find maximum depth %Find latitude and longitude of maximum depth (use the find command) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%