help me understand accumarray
41 ビュー (過去 30 日間)
古いコメントを表示
hi i was reading on accumarray (https://www.mathworks.com/help/matlab/ref/accumarray.html) and I do not understand how matrix A was computed (attached picture) - how the second column of subs was manipulated and the zeros in A. Could someone explain how it is computed?
0 件のコメント
採用された回答
Daniel M
2019 年 10 月 27 日
編集済み: Daniel M
2019 年 10 月 27 日
OK, so the subs matrix represent the rows and columns of the matrix A. (1, 1) represent the first row and first column. (3, 2) represents the 3rd row and 2nd column. If you don't get this, look at the document on ind2sub on this page.
Now the vals are associated with each row in subs (e.g. the first (1, 1) associated with 101, up to (4, 1) with 106). And the values get accumulated in the groups determined by the rows of subs.
Therefore, the two rows of (1, 1) have the values 101 and 104. This adds to 205, which is why A(1,1) = 205. (2, 2) are 102 and 105. Thus, A(2,2) = 207. (3,2) --> 103, A(3,2) = 103. (4,1) --> 106, A(4,1) = 106.
It's pretty clear if you look at the last image on the accumarray page.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Numeric Types についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!