For loop with a big matrix of 800 MB

조회 수: 5 (최근 30일)
Trung Ngo
Trung Ngo 2019년 6월 26일
편집: Trung Ngo 2019년 6월 27일
Hi all,
I am searching through a big matrix file ( nearly 850 MB) and tried to loop through that matrix but it take a massive amount of time. I wonder if are there any method to run a simple for loop in this "big data" matrix. My code is at belown
clearvars;
load('landorocean_250_W.mat')
tA_world = tall(A_world);
tx_world = tall(x_world);
ty_world = tall(y_world);
[m_1,n_1]=size(A_world);
for i=1:m_1
for j=1:n_1
if gather(tA_world(i,j) == -32768)
island_250m_1(i,j)=0;
else
island_250m_1(i,j)=1;
end
end
end
Thank you for your time,
Sincerely,
  댓글 수: 4
Jan
Jan 2019년 6월 27일
@Trung Ngo: In the opriginal question you wrote ">800mb". Of course this might mean 800 TeraByte also. Then only a tall array can catch this. Please post the maximum size and how much free RAM you have. It matters of ">800MB" means 850MB on a computer with 8GB of RAM, or if it means 800GB on a machine with 2 GB RAM.
Trung Ngo
Trung Ngo 2019년 6월 27일
@Jan: Sorry for being unclear. It is 850MB matrix under a computer with 16GB RAM.

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

채택된 답변

Guillaume
Guillaume 2019년 6월 26일
편집: Guillaume 2019년 6월 26일
Using gather as you have done on each individual element of the tall array completely nullifies the advantage of tall arrays. You may as well not have used tall arrays, it would have been faster.
The loop was not needed in the first place:
island_250m_1 = tA_world == -32768; %creates a tall array the same size as tA_world
%now you can call gather if you want to convert that tall array into a concrete array
island_250m_1 = gather(island_250m_1);
  댓글 수: 1
Trung Ngo
Trung Ngo 2019년 6월 26일
Thank you so much for your help !

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by