speed up process of importing data from one vector to another
Afficher commentaires plus anciens
Hi. I have a vector with a timestamp (using Matlab numbers) which I want to import to another vector with a resolution of one second. The second vector is extremely large (since it contains a space for every second of the year 2011).
Here is my code so far: timestNUM: the original timestamp (containing Matlab datenums) VLeist: the original measurements
StartNUM = datenum(['01/01/2011',' 00:00:00'],'dd/mm/yyyy HH:MM:SS');
EndNUM = datenum(['31/12/2011',' 23:59:59'],'dd/mm/yyyy HH:MM:SS');
Step = 1./86400; %One second
timestSecNUM = (StartNUM:Step:EndNUM)';
VLeist_m = 10000.*ones(length(timestSecNUM),1); %the new vector which is to be filled
%the filling of the vector:
Progress = waitbar(0,'Filling high resolution vector with original values...');
x = length(VLeist); ct = 0;
for i = 1:x
k = find(timestSecNUM == timestNUM(i));
VLeist_m(k) = VLeist(i);
ct = ct + 1;
waitbar(ct./x);
end
The problem with my method is that the vectors tiemstNUM and VLeist have a length of over 500000. Because the resolution is supposed to be one second, the vectors VLeist_m and timestSecNUM each have a length of over 31.5 million!
You can imagine how long my loop takes... Any suggestions on how to speed up the process?
Thanks in advance!
1 commentaire
Marc Jakobi
le 10 Déc 2013
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Dates and Time dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!