Borrar filtros
Borrar filtros

Summing squared elements of a column of a matrix

24 visualizaciones (últimos 30 días)
kevin cecere palazzo
kevin cecere palazzo el 6 de Ag. de 2019
Respondida: Star Strider el 6 de Ag. de 2019
for i=1:N
s(i)=sum(V(:,2))/sqrt(n);
t(i)=sum(V(:,2))/sqrt(sum((V(:,i).*V(:,i)));
end
Both s and t are Nx1 vectors, while V is a nxN matrix. In s I summed the elements of each column of V for every element of s. How can I divide, in t, by the square root of the sum of the SQUARED elements of each column of V?

Respuestas (1)

Star Strider
Star Strider el 6 de Ag. de 2019
It’s not clear what you want to do.
Try this:
V = rand(6,5); % Guess What ‘V’ Is
n = size(V,1);
N = size(V,2);
s = sum(V)/sqrt(n); % Sum Over Columns, Divide By ‘sqrt(n)’
t = sum(V)./sqrt(sum(V.^2,2)); % Sum Over Columns, Divide By ‘sum(sqrt(Rows))’

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by