Shift array bitwise and multiply with another array in matlab

Hello All,
I have two arrays for i.e
x=[1,2,3,4];
y=[5,6,7,8];
I want to multiply y with x
and sum the results after
every bit shift excluding
first one.
So result would be in this
order
R1=70 % no bit shift
R2=64 % y= 8 5 6 7
R3=61 % y= 7 8 5 6
..... Till all bit shifted
And finally plot all
result.
How can I achieve this .
Please suggest .
Thanks all of you

 採用された回答

KL
KL 2017 年 10 月 29 日
編集済み: KL 2017 年 10 月 29 日

0 投票

use circshift
R = sum(x.*y)
R1 = sum(x.*circshift(y,1))
R2 = sum(x.*circshift(y,2)) % and so on

2 件のコメント

POKA
POKA 2017 年 10 月 29 日
But for lengthy array say length of 1023 how to use it . shall I use loop
KL
KL 2017 年 10 月 29 日
Yes, or you can let matlab run the loop in the background. For example,
shiftAmount = 0:size(y,2);
R = arrayfun(@(z) sum(x.*circshift(y,z)),shiftAmount)

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Types についてさらに検索

タグ

質問済み:

2017 年 10 月 29 日

コメント済み:

KL
2017 年 10 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by