Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

How can I compute the row differences of an m x n matrix to obtain an m-1 x n matrix; that is, given

enter image description here

how do I obtain

enter image description here

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Maybe this ?

m = {{a, b, c}, {d, e, f}, {g, h, i}};
Differences[m] 
(* {{-a + d, -b + e, -c + f}, {-d + g, -e + h, -f + i}} *)
share|improve this answer
    
Thanks @b.gatesucks I didn't know this function existed! –  sebastian c. Jan 11 '13 at 13:06
6  
@sebastian if you are grateful for answers you should be Accepting some of them too. You haven't done this for a very long time. Why not? –  Mr.Wizard Jan 11 '13 at 13:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.