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

  1. %AIRFOIL Display sparse matrix from NASA airfoil.
  2.  
  3. %    John Gilbert and Cleve Moler, 1-10-91, 10-2-91.
  4. %    Copyright (c) 1984-93 by the MathWorks, Inc.
  5.  
  6. clf
  7. clc
  8. echo on
  9.  
  10. % Finite element mesh for a NASA airfoil, including two trailing flaps.
  11. % The data, stored in the file AIRFOIL.MAT, consists of 4253 pairs
  12. % of (x,y) coordinates of the mesh points and an array of 12,289 pairs
  13. % of indices, (i,j), specifying connections between the mesh points.
  14.  
  15. load airfoil
  16.  
  17. % Scale x and y by 2^(-32) to bring them into the range [0,1].
  18. x = pow2(x,-32); y = pow2(y,-32);
  19.  
  20. pause     % Press any key to continue.
  21.  
  22. clc
  23.  
  24. % Form the sparse adjacency matrix and make it positive definite.
  25.  
  26. n = max(max(i),max(j));
  27. A = sparse(i,j,-1,n,n);
  28. A = A + A';
  29. d = abs(sum(A)) + 1;
  30. A = A + diag(sparse(d));
  31.  
  32. % It takes a few seconds to plot the finite element mesh.
  33.  
  34. gplot(A,[x y])
  35.  
  36. pause     % Press any key to continue.
  37.  
  38. clc
  39.  
  40. % Do a spy plot of the adjacency matrix.
  41.  
  42. spy(A)
  43. disp(' ')
  44. title('The adjacency matrix.')
  45.  
  46. pause     % Press any key to continue.
  47.  
  48. clc
  49.  
  50. % Here are spy plots of symmetric reorderings of the matrix.
  51.  
  52. r = symrcm(A);
  53. spy(A(r,r))
  54. title('Reverse Cuthill-McKee')
  55. pause
  56.  
  57. j = colperm(A);
  58. spy(A(j,j))
  59. title('Column count reordering')
  60. pause
  61.  
  62. m = symmmd(A);
  63. spy(A(m,m))
  64. title('Minimum degree')
  65. pause
  66.  
  67. % End
  68. echo off
  69.