フィルターのクリア

how to partially multiply two diffferent dimention matrix

1 回表示 (過去 30 日間)
kavinda hw
kavinda hw 2017 年 5 月 14 日
コメント済み: kavinda hw 2017 年 5 月 16 日
A[1,2500] and B[500,1]. how can i multiply 500 form A with B and then Skip 250 positions from A And multiply with B. e.g.., A[1 to 500]*B => store then A[250 to 750] * B=> store ,like wise
  2 件のコメント
John D'Errico
John D'Errico 2017 年 5 月 14 日
Interesting. I wonder why two different people are asking the same question?
kavinda hw
kavinda hw 2017 年 5 月 16 日
this is the key technical part of our home work

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

採用された回答

Star Strider
Star Strider 2017 年 5 月 14 日
This works:
A = randi(9, 1, 2500); % Create Data
B = randi(9, 500, 1); % Create Data
for k1 = 1:2
Result{k1} = bsxfun(@times, A(1, (1:500)+(k1-1)*250), B);
end
It produces (500x500) matrices. If you what a different result, I need to know what output you want. It will be easy to change my code to produce it.
  2 件のコメント
kavinda hw
kavinda hw 2017 年 5 月 14 日
編集済み: kavinda hw 2017 年 5 月 14 日
Thank you for quick reply but I need 1x1 matrix
Star Strider
Star Strider 2017 年 5 月 14 日
If you want the dot product (or inner product), change the ‘Result’ assignment to:
Result(k1) = A(1, (1:500)+(k1-1)*250) * B;
That will produce your (1x1) scalar result, as desired.

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

その他の回答 (1 件)

Michael Saniuk
Michael Saniuk 2017 年 5 月 14 日
>> A = rand(1250,1);
>> B = rand(1,500);
>> C = A(1:500,1).*B';
>> D = A(251:750,1).*B';

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by