Importing data from a large data set

1 回表示 (過去 30 日間)
hal9k
hal9k 2020 年 3 月 31 日
コメント済み: Ameer Hamza 2020 年 4 月 1 日
I have a ~30 GB worth of data in a .mat file. The .mat file has m*n (m = ~10^9, n = 10).
I need to run a simulation that derives its value from randomly selected row (from a choice of row 1:m).
The column (1:n) has the simulation parameters.
What is the best way (memory and speed) to do it? Is it possible to do it without loading/importing the entire .mat file in Workspace?

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 3 月 31 日
Yes, you can read data from a mat file without loading it completely. See matfile()https://www.mathworks.com/help/matlab/ref/matlab.io.matfile.html
  2 件のコメント
hal9k
hal9k 2020 年 4 月 1 日
Here is what worked for me.
tic
importData = matfile(filename);
data_info = whos('-file',filename);
row = data_info.size(1);
rand_row= randi([1 row],1);
output = importData.filename(rand_row,:)
toc
Elapsed time = 0.02 sec.
This is great.
Ameer Hamza
Ameer Hamza 2020 年 4 月 1 日
Glad to be of Help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by