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!