Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How to reduce the size of a 144x1 Vector to a 72x1 Vector by adding two consecutive elements in the Original Vector?

1 回表示 (過去 30 日間)
Sudarshan
Sudarshan 2017 年 11 月 19 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hello all, I have a vector which has the dimensions of 144x1. The numbers in the vector repeat after every sixth row. For example, Vector x = [1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6...]';. Now I need to generate another Vector y = [3 7 11 3 7 11 3 7 11...]'; from the Vector x which has the dimensions of 72x1.
Do I need to use a for loop or is there any MATLAB command which will give me this result?
Thank you.

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 11 月 19 日
sum( reshape(x, 2, []) )

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by