Subtraction of rows in matrices
1 view (last 30 days)
Show older comments
Hi All, Hope you can help
I have a 2x5000 matrix and I want to subtract the first row from the second row.
I have tried vectorising them but it isn't working
For example dn=[1 2 4 5 6 7 7
3 5 6 7 8 9 9]
i want to subtract the first row from the second.
Any ideas how i can do this without vecotirsing each row?
Thanks
0 Comments
Answers (2)
Star Strider
on 21 Nov 2017
I do not know what you mean by ‘vectorize’.
Regardless, use the diff funciton:
dn=[1 2 4 5 6 7 7
3 5 6 7 8 9 9]
Result = diff(dn)
Result =
2 3 2 2 2 2 2
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!