I have a 2 Year-Columns in Matlab as shown below:
% Col2 Is always greater than Col1
mat = [2009 2012 ;
2012 2012 ;
2012 2013 ;
I need to do 2009:2012 for row1, 2012:2012 for row2, and so on…. This is not very easy as the size 1:N keeps changing for each pair.
FinalAns = [ 2009
2010
2011
2012 % --
2012 % --
2012
2013 ] ; % --
I cannot use a ‘for’ loop as the data size is very large and I was not successful in using accumarray for this. A vectorized solution would be highly appreciated.
This does what you need: