I'm trying to reshape a vector of 29250 data points into a matrix of 31x943 and 1x17 but the error (Size arguments must be integer scalars) keeps showing up. Any idea how to fix it?
Trials = reshape(Force_signal,[943,31],[1,17]);
Any idea what could be wrong?

 採用された回答

Steven Lord
Steven Lord 2020 年 12 月 15 日

1 投票

Assign the final 17 elements of Force_signal to a separate variable. reshape the first 29233 (=943*31) elements of Force_signal into a 943-by-31 matrix.
Numeric arrays in MATLAB cannot be "jagged arrays". All rows must have the same number of columns and vice versa.

3 件のコメント

Mariam Aldhaheri
Mariam Aldhaheri 2020 年 12 月 15 日
but how would that look like since the original vector consists of 29250 elements so reshaping it into 943 by 31 alone wouldn't work since the matrix would be too small?
Steven Lord
Steven Lord 2020 年 12 月 15 日
If you had an egg carton with two rows of cups, each with six cups you can store a dozen eggs nicely.
If you try to "reshape" those eggs to fit in a different carton with two rows of five cups each, you're going to have eggs left over or you're going to have a few scrambled eggs. The approach I described would set aside the extra two eggs and fit the remaining ten into the 2-by-5 carton.
MATLAB does not let you scramble elements.
Mariam Aldhaheri
Mariam Aldhaheri 2020 年 12 月 16 日
It worked! Thank youu!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by