How to overcome the problem with the function diff used to approximate matrix derivative.
1 view (last 30 days)
Hi, I have an issue using diff function to calculate the derivative of a matrix.
Using diff(X), where X is a matrix m x n matrix, I obtain in output a matrix with m-1 rows. The problem is that I need to concatenate the result of the derivative operation with the X matrix along the columns. In other words, I need to obtain a m x 2n matrix where the first n columns are referring to the X matrix and the last n columns are referring to the derivatives of X's columns along the rows.
How can I deal with this problem? Is it rigth to add a row of zeros before applying the diff function or after applying it in order to have the same numebr of rows before concatenating?