フィルターのクリア

Error using reshape To RESHAPE the number of elements must not change.

1 回表示 (過去 30 日間)
Debalina Pal
Debalina Pal 2018 年 5 月 31 日
コメント済み: Debalina Pal 2018 年 6 月 1 日
This is the code:
d = input('Enter the number of rows(d) : ');
k = input('Enter the number of columns(k) : ');
for i=1:d
for j=1:k
T(i,j)= input('Enter the elements - ');
end
end
T = reshape(T,d,k);
I've put 30 as row number and 3 as column number.After entering the elements it shows this error "Error using reshape To RESHAPE the number of elements must not change." Help me to solve this
  3 件のコメント
jonas
jonas 2018 年 5 月 31 日
Nope, I'm not getting any error.
Kaninika Pant
Kaninika Pant 2018 年 6 月 1 日
You created T with d number of rows and k number of columns. reshape(T,d,k) will not modify anything. Why are you doing this?

サインインしてコメントする。

採用された回答

Kaninika Pant
Kaninika Pant 2018 年 6 月 1 日
編集済み: Kaninika Pant 2018 年 6 月 1 日
I agree with the previous answer. In your code the size of T is changing dynamically. Suppose you ran the code first with d=3, k=2. Then without first clearing the variable T you must have ran your code again with different number of rows and columns. Now if the new number of rows or columns is less than what was defined previously the size of T will not change, only the values at those indices would get altered and so reshape will throw this error.

その他の回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2018 年 5 月 31 日
There is no error in your code. It should have no error if your put in all the d*k elements.
There is no need to run reshape(). Your matrix T is already in dxk.

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by