summation of matrix function
4 次查看(过去 30 天)
显示 更早的评论
I have matrix(8x8) which is content of x and y. I need summation of matrix for(x1,y1), (x2,y2), (x3,y3) and (x4,y4). please help me.
0 个评论
回答(2 个)
Vilém Frynta
2023-4-8
this looks like homework.
i'll try to guide you, but be aware that you won't learn anything by letting others do your homework for you.
m = randi(10, [8 8]) % 8x8 matrix
if you use sum() on the whole matrix, you would get sums from all the columns. if you only want to get sum from specific columns, you can specify that by indexing.
sum(m(:,1)) % sum of all rows from column 1
if you wish to make sums of rows, you will need to rotate (transpose) the matrix.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!