Hey all,
I am trying to convert a matrix A into a new matrix B, by looking at each element in matrix A and whenever the next element (in a row) is different, make a pair and add it to the new matrix B. Also elements with number 0 should be ignored.
As an example: Suppose we have a matrix A, and we want the resulted matrix B.
A = [1 1 1 3 5 B = [1 3 2 2 0 4 5 3 5 2 2 0 0 5] 2 4 4 5 2 5]
This problem could be solved by using a for-loop over all elements in the matrix, however for computational time reasons i am looking for a faster way to convert this, any ideas are welcome 😀
Best Answer