How to use tall to solve out of memory problem

1 visualización (últimos 30 días)
Henriette Larsen
Henriette Larsen el 14 de Feb. de 2021
Respondida: Harsh Mahalwar el 22 de Feb. de 2024
Hello
When I run a ConvertTDMS-code (from File Exchange) in matlab to convert .tdms files to .mat files I get the error "out of memory". I have tried changing the workspace preference and the virtual memory, but it does not seem to solve the problem. Therefore I am now trying to use the tall function as I have read that can do the trick.
I just have to face that I am not enough of a programming-person to understand this more advanced code in the ConvertTDMS file and I can´t figure out how to implement the tall function without changing a lot in the code.
The error seems to come when creating lists of zeros:
%Assign the generic field name
obname=ObjNameList(NameIndex).FieldName;
%Create the 'index' structure
if (~isfield(index,obname))
index.(obname).name=obname;
index.(obname).long_name=long_obname;
index.(obname).rawdatacount=0;
index.(obname).datastartindex=zeros(NumOfSeg,1);
index.(obname).arrayDim=zeros(NumOfSeg,1);
index.(obname).nValues=zeros(NumOfSeg,1);
index.(obname).byteSize=zeros(NumOfSeg,1);
index.(obname).index=zeros(NumOfSeg,1);
index.(obname).rawdataoffset=zeros(NumOfSeg,1);
index.(obname).multiplier=ones(NumOfSeg,1);
index.(obname).skip=zeros(NumOfSeg,1);
end
Please let me know if I need to provide more information in order to get the proper help to solve this.
Best regards,
Henriette
  3 comentarios
Mario Malic
Mario Malic el 15 de Feb. de 2021
Editada: Mario Malic el 15 de Feb. de 2021
Hi,
unfortunately, I don't know so much about tall but you can check the following video on YouTube, there's a tiny tiny bit on the tall in it starting from 39:10.
MATLAB for Analyzing and Visualizing Geospatial Data | Master Class with Loren Shure
Javier Ignacio Camacho Hernandez
Javier Ignacio Camacho Hernandez el 15 de Feb. de 2021
Hi Henriette
I have the same problem. Have you solved?

Iniciar sesión para comentar.

Respuestas (1)

Harsh Mahalwar
Harsh Mahalwar el 22 de Feb. de 2024
Hi Henriette,
I can recognise that you’re trying to use the tall arrays to tackle the out of memory error.
After going through your code, I can confirm that the out of memory error is most probably due to the ones and zeros arrays that are being created, as in these operations MATLAB will be trying to acquire a huge chunk of memory (depending upon the value of NumOfSeg variable).
So instead of changing the entire code, we only need to change these lines of code,
%Assign the generic field name
obname=ObjNameList(NameIndex).FieldName;
%Create the 'index' structure
if (~isfield(index,obname))
index.(obname).name=obname;
index.(obname).long_name=long_obname;
index.(obname).rawdatacount=0;
index.(obname).datastartindex=tall(zeros(NumOfSeg,1));
index.(obname).arrayDim=tall(zeros(NumOfSeg,1));
index.(obname).nValues=tall(zeros(NumOfSeg,1));
index.(obname).byteSize=tall(zeros(NumOfSeg,1));
index.(obname).index=tall(zeros(NumOfSeg,1));
index.(obname).rawdataoffset=tall(zeros(NumOfSeg,1));
index.(obname).multiplier=tall(ones(NumOfSeg,1));
index.(obname).skip=tall(zeros(NumOfSeg,1));
end
You can learn more about the tall arrays and how you can use them to avoid out of memory error from these documentation pages, here:
I hope this helps, thanks!

Categorías

Más información sobre Large Files and Big Data en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by