Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how can i use the reshape command?

2 ビュー (過去 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