How to save only latest ~10 iterations on for loop
Show older comments
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?
Accepted Answer
More Answers (1)
Azzi Abdelmalek
on 12 Jun 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
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!