MATLAB: Multiplying a matrix

multiplication

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

Best Answer

A=[3 5 7;
5 6 0;
5 9 4];
for x = 1 : 3
B(x,:) = sum(A(x,:).^2);
end
B