Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

how can i use the reshape command?

2 Ansichten (letzte 30 Tage)
Muhammad Umer
Muhammad Umer am 6 Okt. 2015
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
i am trying to use the reshape command but there is an error in it.
Input_Generations = reshape(Input_Vector,No_of_Units,No_of_Load_Hours)';
error:
Error using reshape
To RESHAPE the number of elements must not change.
Error in fn(line 13)
Input_Generations = reshape(Input_Vector,No_of_Units,No_of_Load_Hours);
  4 Kommentare
Walter Roberson
Walter Roberson am 6 Okt. 2015
That's nice. But your input data Input_Vector does not happen to have No_of_Units multiplied by No_of_Load_Hours elements in it, which is required if you want to reshape the Input_Vector to exactly that size.
Walter Roberson
Walter Roberson am 6 Okt. 2015
When you use reshape(), the number of elements before and afterwards has to be exactly the same. So if you had 8 elements and tried to reshape to 5 by 2, that would fail because 5 by 2 requires 10 elements of input. 8 elements of input could be reshape()'d to 4 by 2 but not to 5 by 2.
In some cases you might find it necessary to pad your input data with extra elements in order to make it the size you need. For example if you were trying to create 8 x 8 blocks of data but your original data was not a multiple of 64 elements, then you would add enough 0's to the final chunk to bring it up to the needed 64.

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by