multiplying a matrix

1 回表示 (過去 30 日間)
FIR
FIR 2012 年 1 月 10 日
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 件のコメント
FIR
FIR 2012 年 1 月 10 日
chandra can u tell how to process this am struch here for long
http://www.sendspace.com/file/scymbl
Andrei Bobrov
Andrei Bobrov 2012 年 1 月 10 日
i1 = 1:2;
r = 1:20;
out = sum(q.^2.*(i1.'*r))

サインインしてコメントする。

採用された回答

Chandra Kurniawan
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

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2012 年 1 月 10 日
B = sum(A.^2,2);

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by