Summation of certain range of entries/numbers from a large array

1 回表示 (過去 30 日間)
Raashid Hassan
Raashid Hassan 2022 年 4 月 4 日
回答済み: Riccardo Scorretti 2022 年 4 月 4 日
Can you please help me with another query : Suppose I have a large array of numbers , about 2807 entries eg A=(....0 3 4 5 7 8 9 5 5 7 8 9 0 4 1 4 5 7 8 .....) Now I wanna compute sum of certain numbers ,eg from 1500th entry to 1901th entry , likewise summation of other ranges ! How can I do that , kindly elaborate !This is required to develop an algorithm!

採用された回答

Riccardo Scorretti
Riccardo Scorretti 2022 年 4 月 4 日
Hi Raashid,
if you know the range over which you need to compute the sum, it is enough to do like that:
A = rand(2807, 1);
partial_sum = sum(A(1500:1901))
partial_sum = 198.3952

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by