I would like to write a computation that will take a vector of 1xN length and then add adjacent matrix values .

1 回表示 (過去 30 日間)
I would like to write a computation that will take a vector of 1xN length and then add adjacent matrix values .
e.g. [a+b,c+d,e+f,g+h,....etc]
My thoughts were to write something along the lines of n-(n-1), n-(n-2) to calculate this step.
However I don't want to continuously write this for a N=256 row.
How could I do this?
  2 件のコメント
madhan ravi
madhan ravi 2018 年 12 月 15 日
please give an example of your desired output
Victor Fletcher
Victor Fletcher 2018 年 12 月 15 日
input (a,b,c,d,e,f,g,h.....etc.)
output (a+b,c+d,e+f,g+h,....etc.)

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

採用された回答

Stephen23
Stephen23 2018 年 12 月 15 日
編集済み: Stephen23 2018 年 12 月 15 日
Where V is your vector (containing an even number of elements):
V(1:2:end)+V(2:2:end)

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by