How can I save the differents values of a variable which is into a for loop?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, someone can help me with this, I think it has to be easy, but I couldn´t have found the solution.
I need for the following Script, that te value of "K" would be save each script´s loop, with names for example like k1,k2,k3... etc, becuase i need this values for another process, thank you.
for iel=1:nel
index=feeldof(nd,nnel,ndof);
k=fetruss2(el,leng,area,0,beta,1);
kk=feasmbl1(kk,k,index);
kkcf=kk;
end
I´ll be more than glad if someone can help me !!
1 comentario
Stephen23
el 9 de Feb. de 2020
Editada: Stephen23
el 9 de Feb. de 2020
"...with names for example like k1,k2,k3... etc."
Do NOT do that.
Putting numbers into variable names is a sign that you are doing seomthing wrong:
Indexing is neat, simple, easy to debug, and very effiicent (unlike what you are trying to do). All you need to do is preallocate an output array of the right size (you did not tell us what sizes the badly-named k or kk have), and then use indexing to allocate those values on each iteration.
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!