AGROW

Post Reply
matlab1
Site Admin
Posts: 4797
Joined: Thu Dec 15, 2016 9:30 am
Contact:

AGROW

Post by matlab1 »

The variable {0} appears to change size on every loop iteration. Consider preallocating for speed.
matlab1
Site Admin
Posts: 4797
Joined: Thu Dec 15, 2016 9:30 am
Contact:

Re: AGROW

Post 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
Post Reply

Return to “Code Analyzer”

Who is online

Users browsing this forum: No registered users and 1 guest