How to save only latest ~10 iterations on for loop
Mostra commenti meno recenti
I'm trying to run a for loop that will give me a new iteration of a matrix at each time step. The problem comes in because I need to calculate up to 20,000 time steps, but I don't have any where near the memory for that. I'm only interesting in the last ~ 10 time steps. Is there some way to write over or erase the older time steps?
Risposta accettata
Più risposte (1)
Azzi Abdelmalek
il 12 Giu 2014
look at this example, I'm not sur if it's the best way
a=[];
for k=1:20
a(end+1)=k
a(1:end-10)=[]
end
Categorie
Scopri di più su Entering Commands in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!