How to use tall to solve out of memory problem

조회 수: 1 (최근 30일)
Henriette Larsen
Henriette Larsen 2021년 2월 14일
답변: Harsh Mahalwar 2024년 2월 22일
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
Mario Malic
Mario Malic 2021년 2월 15일
편집: Mario Malic 2021년 2월 15일
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
Hi Henriette
I have the same problem. Have you solved?

댓글을 달려면 로그인하십시오.

답변 (1개)

Harsh Mahalwar
Harsh Mahalwar 2024년 2월 22일
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!

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by