Info

此问题已关闭。 请重新打开它进行编辑或回答。

how can i use the reshape command?

1 次查看(过去 30 天)
Muhammad Umer
Muhammad Umer 2015-10-6
关闭: MATLAB Answer Bot 2021-8-20
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 个评论
Walter Roberson
Walter Roberson 2015-10-6
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 2015-10-6
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.

回答(0 个)

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by