i keep getiing ' variable Remainder appears to change size on every loop itearation. Consider prelocating for speed
조회 수: 1 (최근 30일)
이전 댓글 표시
Letters = {'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O' 'P' 'Q' 'R' 'S' 'T' 'U' 'W' 'X' 'Y' 'Z'};
ValueString = num2str(ValueToConvert);
Remainders = [];
while ValueToConvert < 0
Value = 0;
while ValueToConvert >= Base
Value = Value + 1;
ValueToConvert = ValueToConvert - base;
end
Remainders = [Remainders ValueToConvert];
ValueToConvert = Value;
clear Value Remainders
end
댓글 수: 1
darova
2020년 6월 14일
This condition is never met
while ValueToConvert < 0
. ValueToConvert is always 0
답변 (1개)
Sai Sri Pathuri
2020년 7월 9일
This is a warning to indicate that the variable 'Remainders' is not of fixed size and changes its size in every iteration of the loop. This message generally appears because an array is growing by assignment or concatenation, which can be expensive and cause a significant overhead .
Suggested Actions
- Consider preallocating a variable or array before entering the loop by using zeros, ones, cell, or a similar function.
- If you do not know the size of an array before the loop begins, preallocate it with some large size, and then if necessary, shrink it after the loop completes.
You may also refer the following answers
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!