Vectorizing the Notion of Colon (:) – values between two vectors in MATLAB

Your sample output is not legal. A matrix cannot have rows of different length. What you can do is create a cell array using arrayfun: values = arrayfun(@colon, idx1, idx2, ‘Uniform’, false) To convert the resulting cell array into a vector, you can use cell2mat: values = cell2mat(values); Alternatively, if all vectors in the resulting … Read more