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 Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

질문:

2020년 12월 15일

댓글:

2020년 12월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by