home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 3.ddi / DEMOS.DI$ / PENNY.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  1.5 KB  |  68 lines

  1. %PENNY Several views of the penny data.
  2.  
  3. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  4.  
  5. clf
  6. clc
  7. echo on
  8.  
  9. % The file PENNY.MAT contains measurements made at the 
  10. % National Institute of Standards and Technology of the
  11. % depth of the mold used to mint a U. S. penny, sampled
  12. % on a 128-by-128 grid.
  13. % We first load the data and rescale it.
  14.  
  15. load penny.mat
  16. P = (.15/256)*P;
  17.  
  18. % Press any key to continue after pauses.
  19. pause
  20.  
  21. clc
  22.  
  23. % Draw a contour plot with 15 copper colored contour lines.
  24.  
  25. C = copper(35);
  26. set(gca,'colororder',C(21:35,:),'box','on')
  27. hold on
  28. contour(P,15);
  29. n = size(P,1); axis([1 n 1 n]), axis('ij'), axis('square')
  30. hold off
  31.  
  32. pause
  33.  
  34. clc
  35.  
  36. % Draw a pseudocolor plot with brightness proportional to height.
  37.  
  38. pcolor(P)
  39. colormap(copper)
  40. axis([1 n 1 n]), axis('ij'), axis('square'), shading('flat')
  41.  
  42. pause
  43.  
  44. clc
  45.  
  46. % Draw a pseudocolor plot with brightness proportional to the
  47. % Laplacian of the height.  A cell is bright if its height is
  48. % greater than the average of its four neighbors and dark if
  49. % its height is less than the average of its four neighbors.
  50. % This is an unusual "lighting model", but it produces an image
  51. % that looks like a photograph of a penny.
  52.  
  53. D = -del2(P);
  54. pcolor(D)
  55. axis([1 n 1 n]), axis('ij'), axis('square'), shading('flat')
  56.  
  57. pause
  58.  
  59. clc
  60.  
  61. % Finally, produce a 3-D, copper colored, surface plot with
  62. % the Laplacian lighting model.
  63.  
  64. surf(P,D);
  65. axis([1 n 1 n 0 1]), axis('ij'), shading('flat')
  66. view(-20,75)
  67. echo off
  68.