フィルターのクリア

Consider preallocating for speed

4 ビュー (過去 30 日間)
Yudha Bosse
Yudha Bosse 2020 年 12 月 31 日
回答済み: Ameer Hamza 2020 年 12 月 31 日
Hello,
i worked out the following code for my college assignment, and i got the error message as "consider for preallocation of speed "for the variable A. I've got this code from https://www.mathworks.com/matlabcentral/fileexchange/47281-fuzzy-traffic-light-controller for reference. i don't know how to clear this message pls help me.
A(i)=ceil(((x(b(i))+(enter/exit)*time); % warning message
for j=1:A(i)+1
x(b(i))=x(b(i))-exit;
xrand=round(abs(rand(1,4)));
x=x+xrand;
if x(b(i))<=0
x(b(i))=0;
createfigure2(x,y,figure1);
pause(exittime)
break
end
end

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 12 月 31 日
It is not an error message; it is just a warning. Pre-allocation helps make the code faster. Read my answer here to get a general idea: https://www.mathworks.com/matlabcentral/answers/614903-for-loop-preallocation-warning

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by