a 2D version
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

6 lines
212 B

% given idx_sum, which is ordered by col by col
% output row_id & col_id
function [row_id, col_id] = row_col_idx(nely, idx_sum)
row_id = mod(idx_sum-1, nely) + 1;
col_id = floor((idx_sum-1)/nely) + 1;
end