First of all, I don't really know how to formulate the question, so if you understand my question and know a better way to phrase it, please revise.
I have the following Matrixes:
a[n_, m_] := Table[n + m - i - j, {i, 1, n}, {j, 1, m}]
b[n_, m_] := Round[Table[(n*m/2)*(1 + 2 j/m), {j, 1, m}]]
(these are just chosen to test the sequence).
Where a[n,m]
is a nxm
Matrix, and b[n,m]
a vector of length m
.
I want to make a sequence that accumulates a[n,m]
,
but, when it becomes higher than b[n,m]
at a certain m
, it has to take the respective value of b[n,m]
and continue the accumulations (or another exception).
I tried a couple of ways like with FoldList
and MapThread
or RecurrenceTable
. But I just didn't get there. I think there is a simple way which I just didn't think of.
Finally I just did it by hand (and called it c[n,m]) with a[3,8]
and b[3,8]
a[3,8] =
{{9, 8, 7, 6, 5, 4, 3, 2},
{8, 7, 6, 5, 4, 3, 2, 1},
{7, 6, 5, 4, 3, 2, 1, 0}}
b[3,8] = {15, 18, 21, 24, 27, 30, 33, 36}
c[3,8] = {{9, 17, 21, 24, 27, 30, 33, 35}, {8, 15, 21, 24, 27, 30, 32, 33}, {7, 13, 18, 22, 25, 27, 28, 28}}
I hope you can help me out.