How do I load only part of a table saved to a .mat file?

조회 수: 24 (최근 30일)
Kyle Padilla
Kyle Padilla 2022년 3월 23일
답변: Kyle Padilla 2022년 3월 30일
I have some large tables stored in .mat files and was wondering if there is a way I could load only some of the data into MATLAB (for example, a subset of rows or columns in a table). I read about the matfile function, but it doesn't seem to work with tables. Whenever I try to load part of a table, I get an error telling me to load the whole table. Is there some way to load partial data that works for tables?

채택된 답변

Kyle Padilla
Kyle Padilla 2022년 3월 30일
I found out you can make your table a tall table, which provides a way to work with large amounts of data. You use the tall function and pass in your table. You can write your table to a folder of .mat files using the write function. You then create a datastore and convert it to a tall table. Finally, you can get a subset of the tall table and use the gather function to get the results.

추가 답변 (2개)

Walter Roberson
Walter Roberson 2022년 3월 23일
No, there is no method provided for that.

Peter Perkins
Peter Perkins 2022년 3월 24일
You might look into using datastores, which would, in effect, allow you to load pieces.
  댓글 수: 3
Walter Roberson
Walter Roberson 2022년 3월 29일
I believe that the idea is that if the table were instead stored in a file such as a .xlsx file, then tabularDataStore would be able to process it piecewise, chunks of rows at a time.
Kyle Padilla
Kyle Padilla 2022년 3월 30일
That might work yeah. I think I figured it how I can do this with .mat files though. Gonna post an answer to my question so others can use it for future reference.

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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by