Adding matrices rows having the same id
显示 更早的评论
Hello, I would like to sum rows of two matrices if they have the sam id (first column). For instance, I have a matrix A and matrix B:
A = [
1 4 5 6;
2 5 5 3;
3 9 8 2];
B = [
4 5 6 2;
2 9 4 1;
1 5 7 9;
3 5 6 7;
1 4 5 3];
I would like to get matrix C such that it looks at the first column and add the other columns if id is the same in both matrices.
C = [
1 13 17 18;
2 14 9 4;
3 14 14 9;
4 5 6 2];
Thank you
3 个评论
Guillaume
2020-3-22
When you ask a question on Answers, it's with the understanding that your question and its answer may be useful to others. Therefore we do not delete questions once they've been answered and we really don't like when the poster remove all useful content.
It's very disrepectful of the volunteers to treat us as consultants. If you want private support, Answers is not the right forum.
Mo H
2020-3-22
Adam Danz
2020-3-22
Thanks for restoring the question and for the compliment, Mohammad.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 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!