Summing squared elements of a column of a matrix

52 ビュー (過去 30 日間)
kevin cecere palazzo
kevin cecere palazzo 2019 年 8 月 6 日
回答済み: Star Strider 2019 年 8 月 6 日
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?

回答 (1 件)

Star Strider
Star Strider 2019 年 8 月 6 日
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))’

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by