How to subtract entire column of matrix
1 次查看(过去 30 天)
显示 更早的评论
Suppose I have a 5x2 matrix such as
a = [1.20;.976;.833;.702;.543];
b = [1663;1058;953;802;744];
z = [a,b];
I want subtract each column such that 1.20 - .976 - .833 - .702 - .543 and 1663 - 1058 - 953 - 802 - 755
The main goal is to get a 1x2 matrix with the difference of these columns which in this case would be
[-1.854,-1905]
I tried using the diff and sum command but they would just add everything up which isn't the same as subtracting each value. I know I can easily use a calculator to find this answer but if I had a 20x2 matrix it wouldn't be as practical.
What would be the simplest way to calculate this?
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!