I have a row of 1308 values and I need the total every 12 rows. So I need the sum of rows 1-12 and then again for the next 12 numbers

1
1
1
5
5
1
1
1
10
1
1
1
so basically I need the sum of all these numbers in this entire column for the 12 rows and then i need to get the values for the next 12 rows

 採用された回答

chemPolonium
chemPolonium 2020 年 2 月 10 日
Maybe you can use reshape and sum function.
For example:
a = rand(1, 1000); % this create a rand vector of 1000 dims
b = reshape(a, 10, 100); % this convert vector a to a matrix of 10 rows and 100 columns
c = sum(b); % this calculate the sum of each column

4 件のコメント

b = reshape(Excel, 12, 109); % this convert vector a to a matrix of 10 rows and 100 columns
c = sum(b); % this calculate the sum of each column
it tells me
Error using reshape
To RESHAPE the number of elements must not change.
Error in Untitled2 (line 23)
b = reshape(Excel, 12, 109);
This error occurs when the numbers of elements are not equal for reshaped and origin matrix. You can check the size of the origin matrix (in your program I think it's Excel) by using numel or size function.
Walter Roberson
Walter Roberson 2020 年 2 月 10 日
編集済み: Walter Roberson 2020 年 2 月 10 日
What shows up for
size(Excel)
You all are amazing! Thank youuuu

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeOperators and Elementary Operations についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by