"Jos (10584)" wrote in message <firstname.lastname@example.org>... > "Naresh Pai" wrote in message <email@example.com>... > > I have a vector with indices, for e.g. > > > > b = [1 4 7] > > > > Using these indices, I am trying to develop a matrix that looks like this > > a =[1 0 0; > > 2 3 4; > > 5 6 7] > > > > In other words, the indices variable (b) indicates end-points of the matrix a for each row. This looks simple but been trying to figure out how to generalize the code when b could be of different sizes. Any hints would be appreciated. > > > > Thanks, > > Naresh > > I got confused ... what would A look like if B = [4 1 6 2] for instance? > > ~ Jos
Jos, Thanks for your post. B results from a cumsum operation, so it would either ascending (e.g. [1 3 5 9]), or remain constant at some elements ([1 2 2 4]). In the example you provided, the second and fourth element are descending. I have put few other examples to illustrate my requirement. Thanks.