Consider preallocating for speed
2 views (last 30 days)
Show older comments
Yudha Bosse on 31 Dec 2020
Answered: Ameer Hamza on 31 Dec 2020
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
Ameer Hamza on 31 Dec 2020
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
More Answers (0)
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!