Cody

Problem 771. Map all the indices of an Array Indices into a Vector giving Index vs Row and Column

Solution 2196850

Submitted on 7 Apr 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Fail
% Vectorization of ind2sub m=zeros(10); [zrc(:,1),zrc(:,2)]=ind2sub(size(m),1:numel(m)); assert(isequal(indices2rc_vector(m),zrc))

Not enough input arguments. Error in ind2sub (line 45) vi = rem(ndx-1, siz(1)) + 1; Error in indices2rc_vector (line 2) [irc1 irc2] = ind2sub(m) Error in Test1 (line 4) assert(isequal(indices2rc_vector(m),zrc))

2   Fail
m=rand(4); [zrc(:,1),zrc(:,2)]=ind2sub(size(m),1:numel(m)); assert(isequal(indices2rc_vector(m),zrc))

Not enough input arguments. Error in ind2sub (line 45) vi = rem(ndx-1, siz(1)) + 1; Error in indices2rc_vector (line 2) [irc1 irc2] = ind2sub(m) Error in Test2 (line 3) assert(isequal(indices2rc_vector(m),zrc))

3   Fail
m=zeros(floor(20*rand)); [zrc(:,1),zrc(:,2)]=ind2sub(size(m),1:numel(m)); assert(isequal(indices2rc_vector(m),zrc))

Not enough input arguments. Error in ind2sub (line 45) vi = rem(ndx-1, siz(1)) + 1; Error in indices2rc_vector (line 2) [irc1 irc2] = ind2sub(m) Error in Test3 (line 3) assert(isequal(indices2rc_vector(m),zrc))