Here's a simplified example of my problem:
A = [2 7 11; 5 9 11]; % This is my starting array
I'd like to obtain
B = [2 3 4 5 7 8 9 11]; % in other words [2:5 7:9 11:11]
Right now, my solution is
B = arrayfun(@(x,y) colon(x,y), A(1,:), A(2,:), 'UniformOutput', false);
Then I use [B{:}] as a comma-separated-list to index another array.
Since I'm doing this in a for loop where A can have hundred of thousands of columns, I'd like to avoid to create a cell by horizontally concatenating output arguments from arrayfun to improve memory layout efficiency.
Do you know if it's possible or if there's a smarter approach?
Thanks in advance!
Best Answer