MATLAB: Problem with the sum function

homeworkmatrixsum

Hello everyone, im trying to solve this exercise
but appear a error that i dont know how to solve
"Error using ^
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead."
this is my code:
function [norma2] = normalizacao(X)
[n, m] = size(X);
for i = 1:n
for j = 1:m
norma2(i, j) = sqrt(sum(X(i, :)^2))
end
end
end
Someone can help me?

Best Answer

norma2 = sqrt(sum(X.^2))