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?

 Respuesta aceptada

Steven Lord
Steven Lord el 15 de Dic. de 2020

1 voto

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 comentarios

Mariam Aldhaheri
Mariam Aldhaheri el 15 de Dic. de 2020
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 el 15 de Dic. de 2020
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 el 16 de Dic. de 2020
It worked! Thank youu!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 15 de Dic. de 2020

Comentada:

el 16 de Dic. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by