フィルターのクリア

how to perform this multiplication form or by using loop?

1 回表示 (過去 30 日間)
Aimen Mujahid
Aimen Mujahid 2017 年 2 月 26 日
回答済み: Star Strider 2017 年 2 月 26 日
function y=a
Q=[1 2;3 4;5 6];
X=[1 0 1;0 1 0];
disp(Q);
s=[2000 3000;1000 4000;2000 3000];
disp(s);
a=[(s(1,1))*(Q(1,1)) (s(1,2))*(Q(1,2));
(s(2,1))*(Q(2,1)) (s(2,2))*(Q(2,2));
(s(3,1))*(Q(3,1)) (s(3,2))*(Q(3,2))];
disp(a);
y=sum(a(:));
end

採用された回答

Star Strider
Star Strider 2017 年 2 月 26 日
No loop needed. you can calculate ‘a’ with element-wise operations:
a = Q.*s;

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by