필터 지우기
필터 지우기

How can I store large strings in an array?

조회 수: 1 (최근 30일)
Ed Frank
Ed Frank 2020년 3월 24일
댓글: John D'Errico 2020년 3월 24일
Dear Matlab community,
I need to store large strings coming from fread in an array. With a conventional array, this fails with the "Out of memory." error.
I am not really into this topic but for handling large data sets I found two possible solutions which both do apparently not work for my situation:
1) Using matfile: This works great for arrays of numbers, but trying to use strings with a command like
matfileObj.stringArray(i) = char(fread(...));
results in the error "... is of type string. To use ... load the entire variable." However, I am not able to do this for the above-mentioned lack of memory.
2) Using tall: Unfortunately, the file that I work on is in a very ugly binary format that I think can't connect with a datastore. I could, however, initialise a string array of the needed length and generate a tall array from this. But now it seems I can't replace the initialisation strings with the real data; even the command
tallStringArray(i) = "";
fails with "For A(m,n,...) = B, m must be either a colon (:) or a tall logical vector." So apparently, I can't change single entries in the tall array.
Do you have any idea how I can store these large strings?
Many thanks for sharing your thoughts,
Ed
  댓글 수: 3
Ed Frank
Ed Frank 2020년 3월 24일
fread() from a binary file, converted to a string. This string has to be put in a string array, after this the next string is read from the file, put in the array and so on. The strings' length is known, but differs between the strings.
John D'Errico
John D'Errico 2020년 3월 24일
You have large strings of varying sizes? Then learn about cell arrays, which can store them without wasting space because some are larger than others. If you use a regular array, then the array needs to be rectangular, so is far less effcieitn in terms of memory.

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

답변 (0개)

카테고리

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