Importdata extremely slow every 5th time or so

11 visualizaciones (últimos 30 días)
Cedrik Wiberg
Cedrik Wiberg el 29 de Jul. de 2020
Comentada: Joren Vanlaere el 23 de Mayo de 2021
Hi,
I am running battery experiments and each cycle becomes two files (one charge, and one discharge). I use importdata to read this and it works well and takes about 0.5 seconds per file. But at random intervals, it takes much longer for a few files, then speeds up again. The files are tab-separated textfiles of about 143 kB each and contain about 12x1000 elements, so they should be quite easily digested, I thought. I have tried the other import functions, but importdata is the only one that I managed to get to work.
Can somebody help me clear this problem? I have quite many cycles on different batteries that I need to read, and it would save me a lot of time. Thanks a lot in advance!
function [E,I,t] = RFBread(filename,state)
if strcmp(state,'Charge') %% Because the charge file has one extra row och BS in the beginning.
nheader=56;
else
nheader=55;
end
fid = fopen(filename);
counter1=0;
bbline='0';
while strcmp('CURVE2 TABLE',bbline)==0&&(bbline(1)==-1&&counter1>nheader)==0
counter1=counter1+1;
bbline=fgetl(fid); % Read/discard line.
end
headerlinesIn=counter1;
counter1=counter1-nheader-1;
C=cell(counter1,12);
tic
A=importdata(filename,'\t',headerlinesIn);
toc
Maximum possible array: 5343 MB (5.603e+09 bytes) *
Memory available for all arrays: 5343 MB (5.603e+09 bytes) *
Memory used by MATLAB: 2978 MB (3.123e+09 bytes)
Physical Memory (RAM): 16259 MB (1.705e+10 bytes)
* Limited by System Memory (physical + swap file) available.
Elapsed time is 1.008990 seconds.
Elapsed time is 0.516284 seconds.
cycle 1
Elapsed time is 0.572899 seconds.
Elapsed time is 0.462640 seconds.
cycle 2
Elapsed time is 0.707857 seconds.
Elapsed time is 0.478998 seconds.
cycle 3
Elapsed time is 0.476164 seconds.
Elapsed time is 0.476082 seconds.
cycle 4
Elapsed time is 0.481227 seconds.
Elapsed time is 0.435977 seconds.
cycle 5
Elapsed time is 0.477300 seconds.
Elapsed time is 15.177779 seconds.
cycle 6
Elapsed time is 25.158126 seconds.
Elapsed time is 12.903479 seconds.
cycle 7
Elapsed time is 0.476266 seconds.
Elapsed time is 0.468129 seconds.
cycle 8
Elapsed time is 0.455551 seconds.
Elapsed time is 0.460165 seconds.
cycle 9
Elapsed time is 0.461218 seconds.
Elapsed time is 0.455580 seconds.
cycle 10
Elapsed time is 0.456271 seconds.
Elapsed time is 0.458112 seconds.
cycle 11
Elapsed time is 0.458173 seconds.
Elapsed time is 0.487673 seconds.
cycle 12
Elapsed time is 0.465211 seconds.
Elapsed time is 0.473928 seconds.
cycle 13
Elapsed time is 0.449914 seconds.
Elapsed time is 0.469210 seconds.
cycle 14
Elapsed time is 0.478202 seconds.
Elapsed time is 0.468108 seconds.
cycle 15
Elapsed time is 0.592519 seconds.
Elapsed time is 0.476884 seconds.
cycle 16
Elapsed time is 15.189158 seconds.
Elapsed time is 25.170355 seconds.
cycle 17
Elapsed time is 10.239965 seconds.
Elapsed time is 0.480640 seconds.
cycle 18
Elapsed time is 0.457654 seconds.
Elapsed time is 0.441267 seconds.
  2 comentarios
Cedrik Wiberg
Cedrik Wiberg el 6 de Ag. de 2020
I would be very grateful if anyone has some insight on this matter. Thanks! :)
Joren Vanlaere
Joren Vanlaere el 23 de Mayo de 2021
Had the same problem and this worked for me: https://nl.mathworks.com/matlabcentral/answers/250577-does-matlab-become-slow-and-unusable-when-working-in-a-folder-with-many-files#answer_197100

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Data Import and Analysis en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by