Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

how can i use the reshape command?

1 visualización (últimos 30 días)
Muhammad Umer
Muhammad Umer el 6 de Oct. de 2015
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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 comentarios
Walter Roberson
Walter Roberson el 6 de Oct. de 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 el 6 de Oct. de 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.

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by