Store each value generated in a for loop
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a bit of code which generates a value P and updates it every iteration. How can i store each of these values generated and then plot them on a graph?
0 comentarios
Respuestas (1)
David Hill
el 9 de Mzo. de 2022
for k=1:100
p(k)=%your update for p
end
plot(p);
2 comentarios
David Hill
el 11 de Mzo. de 2022
Use a cell array. Your sizes each iteration might be different based on the number of nonzeros.
P=cell(1000,1);
for n = 1:1000
P{n} = nonzeros(Q_new.*C);
end
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!