Skip to content

Instantly share code, notes, and snippets.

@jagbolanos
Created March 3, 2011 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jagbolanos/853627 to your computer and use it in GitHub Desktop.
Save jagbolanos/853627 to your computer and use it in GitHub Desktop.
Create a rectangular field
function [nrows, ncols, nslices] = fieldsize(cols, slices)
%cols = 102; % in this particular case FieldSize / 0.0977 right now an even number is necessary
%slices = 40; %in this particular case FieldSize / 0.25 right now an even number is necessary
%edgeS.rows = repmat(256,1,squareFieldSizeCols*squareFieldSizeSlices);
%edgeS.cols = repmat((256-squareFieldSizeCols/2+1):(256+squareFieldSizeCols/2),1,squareFieldSizeSlices); % 512 / 2 => 256
%edgeS.slices = repmat((64-squareFieldSizeSlices/2+1):(64+squareFieldSizeSlices/2),1,squareFieldSizeCols) %1
ncols = zeros(1,cols*slices);
i = 1;
for v=(256-cols/2+1):(256+cols/2)
ncols(i:i+slices-1) = repmat(v,1,slices);
i = i + slices;
end
nslices = repmat((64-slices/2+1):(64+slices/2),1,cols);
nrows = repmat(256,1,cols*slices);
%scatter(ncols,nslices);
end
@jagbolanos
Copy link
Author

You can call this method like this:
% 10 x 10 Field
[edgeS.rows edgeS.cols edgeS.slices] = fieldsize(102, 40);

% 5 x 5 Field
[edgeS.rows edgeS.cols edgeS.slices] = fieldsize(50, 20);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment