Error using reshape, Size arguments must be real integers.
27 ビュー (過去 30 日間)
古いコメントを表示
Hi, please, i have a question. every time i run this function on Matlab
my=repmat(mean(reshape(Y,T,N)),T,1);
i got error message saying that:
Error using Reshape.
(size arguments must be real intergers).
How can i solve this problem please ?
0 件のコメント
採用された回答
Iain
2013 年 6 月 20 日
You could ensure that T, and N are positive whole numbers...
3 件のコメント
James Tursa
2013 年 6 月 20 日
T needs to be an integer value. If length(Y) is not a whole multiple of N, then it won't be in your equation for T.
その他の回答 (1 件)
Yan Jiang
2023 年 9 月 12 日
Check the type of variables T and N and verify they are integer would solve this this problem.
1 件のコメント
Steven Lord
2023 年 9 月 12 日
The type of T and N isn't what's important, though casting them to an integer type could accidentally resolve the problem. The values of T and N must be integer values. For example, I can reshape an array with 12 elements into a 3-by-4 array:
x = 1:12
y = reshape(x, 3, 4)
But I can't reshape it to have 8 columns because having an array with 1.5 rows doesn't make sense.
try
z = reshape(x, [], 8) % WILL ERROR
catch ME
fprintf("This call threw error:\n%s\n", ME.message)
end
Trying to specify 1.5 rows will throw an error as well.
try
z = reshape(x, 1.5, []) % WILL ERROR
catch ME
fprintf("This call threw error:\n%s\n", ME.message)
end
Nor can I reshape it to have 0 rows.
try
z = reshape(x, 0, []) % WILL ERROR
catch ME
fprintf("This call threw error:\n%s\n", ME.message)
end
A complex number of rows won't work either.
try
z = reshape(x, 3i, []) % WILL ERROR
catch ME
fprintf("This call threw error:\n%s\n", ME.message)
end
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!