How do I preallocate this variable so that I can remove my warning and test whether my while loops are infinite or whether my code is just computing really slowly?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Syed Awais
am 9 Okt. 2020
Kommentiert: Ameer Hamza
am 9 Okt. 2020
I only have these variables left to "fix" and then my code will be "green", free from any errors or any warnings, but I do not know how to preallocate this variable, which I'm getting a warning of "The variable result appears to change for every loop iteration" for:
result(i+1,1)=phi;
result(i+1,2)=T_AF;
Currently, my code execution is just taking forever to finish and I'm not sure if it's my while loops or if it's not pre allocating the aforementioned variables,
My for loop is:
for i = 0:1:15
Thank you for your help!
0 Kommentare
Akzeptierte Antwort
Stephen23
am 9 Okt. 2020
Bearbeitet: Stephen23
am 9 Okt. 2020
result = nan(16,2); % preallocate
for ...
2 Kommentare
Ameer Hamza
am 9 Okt. 2020
@Syed, preallocation of just 32 elements isn't such a significant speed issue. The likely cause is your algorithm.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!