示例:
k=5;
a=zeros(k,k);
for m=1:k
for n=1:k
a(m,n)=1/(m+n-1);
end
end
for i=1:1:10
b(i)=i+20;
end
Explanation
The size of the indicated variable or array appears to be changing with each loop iteration. Commonly, this message appears because an array is growing by assignment or concatenation. Growing an array by assignment or concatenation can be expensive. For large arrays, MATLAB must allocate a new block of memory and copy the older array contents to the new array as it makes each assignment.
Programs that change the size of a variable in this way can spend most of their run time in this inefficient activity. There is also significant overhead in shrinking