Error using Reshape Function

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?

 Accepted Answer

Steven Lord
Steven Lord on 15 Dec 2020
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 Comments

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?
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.
It worked! Thank youu!

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!