multiplying a matrix
2 次查看(过去 30 天)
显示 更早的评论
i have a matrix
A=[3 5 7
5 6 0
5 9 4]
i want to square each element and add along row wise and display
for ex
3^2+5^2+7^2
ans is 89
so i need as
89
71
122
pleas guide
15 个评论
采纳的回答
Chandra Kurniawan
2012-1-10
A=[3 5 7;
5 6 0;
5 9 4];
for x = 1 : 3
B(x,:) = sum(A(x,:).^2);
end
B
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!