daily pastebin goal
27%
SHARE
TWEET

octb

a guest Apr 3rd, 2013 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function C = octb(n,l)
  2. if (l<1)
  3.         C = ones(n,n,n);
  4.         return;
  5. end
  6. [x y z] = meshgrid(0:n-1,0:n-1,0:n-1);
  7. d1 = x+y+z;
  8. d2 = n-1-x+y+z;
  9. d3 = x+n-1-y+z;
  10. d4 = n-1-x+n-1-y+z;
  11. seps = (n-1)/2/l:(n-1)/l:(n-1);
  12. seps(1:ceil(l/2)) = floor(seps(1:ceil(l/2)));
  13. seps(ceil(l/2+1):l) = ceil(seps(ceil(l/2+1):l));
  14. seps = [seps (2*n-2-seps) (seps+2*n-2)];
  15. b = zeros(n,n,n);
  16. for ii = 1:(2*l)
  17.         s = seps(ii);
  18.         b((d1==s)|(d2==s)|(d3==s)|(d4==s)) = 1;
  19. end
  20. C = b+1;
  21. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top