Specific Row/Column addition and subtraction in a N by M matrix

2 ビュー (過去 30 日間)
WARRIOR24
WARRIOR24 2021 年 4 月 21 日
回答済み: David Hill 2021 年 4 月 21 日
I am trying to add and subtract specfic rows and colums, the sum function is not working working for me; it is either suming up all of the values or adding all columns only.
1.1125 2.0641 2.3183 1.8751 1.2631 0.6625
3.4084 5.1874 5.2771 3.6026 2.1510 1.0079 1.) I am trying to sum up all the outside elements starting from
10.000 10.000 10.000 5.1074 2.7302 1.2181 3.4084 and ending at 2.8216
5.3388 6.2794 6.0136 4.0968 2.4445 1.1343 2.) As well as the inner elements starting from
2.9655 3.7652 3.6784 2.8216 1.8166 0.8745 10.000 to 10.000 (sideways) and from 10.000 to 3.6784
1.6518 2.1375 2.1130 1.6946 1.1259 0.5472 (downwards). This should be 3 elements in both directions
0.8781 1.0199 0.9417 0.7178 0.4451 0.1884 3.) then subtract the outter from inner with the abs function
0.4931 0.6300 0.6188 0.5039 0.3377 0.1618
0.2869 0.3881 0.3997 0.3411 0.2401 0.1213
0.1692 0.2358 0.2506 0.2208 0.1603 0.0832
0.0971 0.1354 0.1462 0.1313 0.0971 0.0511
0.0472 0.0625 0.0674 0.0611 0.0456 0.0242

採用された回答

David Hill
David Hill 2021 年 4 月 21 日
abs(sum(m(2,1:3))+sum(m(3:5,4))-sum(m(3,1:3))-sum(m(4:5,3)));

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by