How to write a matlab code to perform moving compuation for any equation?

1 回表示 (過去 30 日間)
Lets say I have a vector of 1000 random numbers and want to sum every 30 numbers of the vector and store it in a variable.

採用された回答

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023 年 1 月 8 日
編集済み: Sulaymon Eshkabilov 2023 年 1 月 8 日
There are a couple of ways to do it, e.g.:
V = randi([-10, 100], 1, 1000);
n = 1:30:numel(V);
for ii=1:numel(n)-1
Vs(ii)=sum(V(n(ii):n(ii+1)));
end
numel(Vs)
ans = 33

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by