New matrix containing difference between row elements of original

后端 未结 3 1189
南笙
南笙 2020-12-22 09:53

I want to take an existing MxN matrix and create a new M-1xN matrix such that for each columns, the elements are the difference between adjacent row elements of the original

3条回答
  •  情书的邮戳
    2020-12-22 10:26

    In case you want to subtract the columns of a matrix (and not the rows), try:

    col.diff = t(diff(t(mat)))
    

提交回复
热议问题