Borrar filtros
Borrar filtros

How to fix "The size of the indicated variable or array appears to be changing with each loop iteration?"

4 visualizaciones (últimos 30 días)
Hello Guys,I am student and doing some project on Torsional constant for any cross section . I am using mat lab and i could not fix one error message.Is there any one can help me? (I got this code on internet which one gentle man did his research on this field ) Here is the code fragment
A = sparse( size(coordinates,1), size(coordinates,1) );
for j = 1 : size(elements3,1)
A(elements3(j,:),elements3(j,:)) = A(elements3(j,:),elements3(j,:)) + ...stima3(coordinates(elements3(j,:),:));
end
Here is the error message "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"
  3 comentarios
Abe Ada
Abe Ada el 10 de Jun. de 2014
Editada: Abe Ada el 10 de Jun. de 2014
oh,element 3 contains coordinate elements of triangles for which user enters from key bored or load it from file.
eg
load elements3.dat;or
element3 contains( Node1,node2,node3)
node1(x1,y1),node2(x2,y2) ,node3(x3,y3)-----
Henric Rydén
Henric Rydén el 11 de Jun. de 2014
What is the size of coordinates?
What is the size of elements3? Do you know that size before the loop begins?

Iniciar sesión para comentar.

Respuestas (1)

merina amon
merina amon el 18 de Ag. de 2020
facing the same problem, need help with this.
for k=1:101
t=tk(k);
for i=3:4
x(k,i-2)=0;
for j=1:4
x(k,i-2)=x(k,i-2)+(real(S(j))*real(V(i,j))-imag(S(j))*imag(V(i,j)))*cos(imag(D(j,j))*t);
x(k,i-2)=x(k,i-2)+(imag(S(j))*real(V(i,j))-real(S(j))*imag(V(i,j)))*sin(imag(V(i,j))*t);
x(k,i-2)=x(k,i-2)*exp(-real(D(j,j))*t);
end

Categorías

Más información sobre Performance and Memory en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by