Optimising or removing For loop : Help required to optimise script to save memory
Show older comments
Can anyone please suggest if there is a way to optimise the following for loop: I have a time vector which is incrementing every 1024 samples. Increment value is not always consistent, but is close to 0.25s (I need the real values) The time stamp for each sample should have really been updated, but it was never done. I need to now update the time stamps on each of my time samples making sure I use the real values to constrain the time-stamps.
The time matrix I am reading is HUGE, so any optimisation will save me runtime+memory. I only have a 4Gb RAM and a standard 3.1GHz PC.
My bulky script
t1=datevec(DASI.time(1));
time=[];
for i=1:length(A)
t2=datevec(DASI.time(A(i)+1));
du=etime(t2,t1);
dt=du/A(1);
s0=t1(1,6);
y0=t1(1,1);
m0=t1(1,2);
d0=t1(1,3);
h0=t1(1,4);
min0=t1(1,5);
temp_time=datenum(y0,m0,d0,h0,min0,(s0:dt:s0+du-dt))';
time=[time;temp_time];
t1=t2;
end
Hope someone can help me optimise this bit of code.
Thanks
Accepted Answer
More Answers (0)
Categories
Find more on Language Fundamentals 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!