Page 1 of 1

AGROW

Posted: Tue Jan 26, 2021 7:28 am
by matlab1
The variable {0} appears to change size on every loop iteration. Consider preallocating for speed.

Re: AGROW

Posted: Wed Feb 10, 2021 8:04 am
by matlab1
When you want to fill a variable in a loop, it is recommended to create an empty array before filling.

for example,


for k=1:100
sp(k)= sin(10*k-7);

end

sp is filling inside a loop, it is better to use the following MATLAB code :


sp = zeros(100,1)
for k=1:100
sp(k)= sin(10*k-7);

end