woss

Untitled

Nov 22nd, 2011
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.37 KB | None | 0 0
  1. M = zeros(400, 300);
  2.  
  3. for i = 1 : 300
  4.     if i <= 100
  5.         j = 2*i
  6.     else i <= 300
  7.         j = 0.5*i + 150
  8.     end
  9.    
  10.     M(i, j) = 100
  11. end
  12.  
  13. for k = 1 : 100000
  14.     for i = 2 : 399
  15.         if i <= 99
  16.             j_max = 2*i
  17.         elseif i <= 299
  18.             j_max = 0.5*i + 150
  19.         else
  20.             j_max = 299
  21.         end
  22.        
  23.         for j = 2 : j_max
  24.             M(i, j) = 0.5*(M(i-1,j) + M(i+1,j) + M(i,j-1) + M(i,j+1))
  25.         end
  26.     end
  27. end
  28.  
Advertisement
Add Comment
Please, Sign In to add comment