Solve matrix reshape error

Hello,
I have a 6 x 1200 matrix. For each row, I want to sum columns 1:600 and 601:1200 using the code below.
sum_dGwdt_gwd = squeeze(sum(reshape(sum_dGwdt_gwd,size(sum_dGwdt_gwd,1),600,[]),2)/50);
However, I keep getting the following error.
Error using reshape
Product of known dimensions, 3600, not divisible into total number of elements, 6.
It would be helpful if anyone can point out what I'm doing wrong.
Thank you.

1 件のコメント

Elizabeth Yeap
Elizabeth Yeap 2019 年 12 月 16 日
編集済み: Elizabeth Yeap 2019 年 12 月 16 日
Guys, I have solved the problem on my own. Thanks.

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

回答 (1 件)

KSSV
KSSV 2019 年 12 月 16 日

0 投票

A = rand(6,1200) ;
iwant = [sum(A(:,1:600),2) sum(A(:,601:end),2)] ;

1 件のコメント

Elizabeth Yeap
Elizabeth Yeap 2019 年 12 月 16 日
Thanks @KSSV, but I'm getting an error for your code above. Anyways, I have solved the problem on my own. Thank you for your input.
Index in position 2 exceeds array bounds (must not exceed 1).

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

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

製品

質問済み:

2019 年 12 月 16 日

コメント済み:

2019 年 12 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by