Error using vertcat(out of memory)

hi,
I want to concatenate two matrix , A is 64 * 9000 and B is 49 * 9000( B is in "For" loop, and in each Loop , B(matrix)'s Row changes,but the columns is fixed(9000))
so i use this code for concatenate them: C=[A;B];
but , in 150th loop , i saw this Error: " Error using vertcat out of memory . Type Help Memory for Your option."
i can't solve it, can anybody help me ? (my installed memory(RAM) is 6 gig)

답변 (2개)

Orion
Orion 2014년 11월 10일
편집: Orion 2014년 11월 10일

0 개 추천

Hi,
you're saying that the numbers of rows of B changes at each iteration.
so B increases at each iteration ? and A ?
what is it size when it crashes ? use disp(size(B)) in the loop, so you will see the result in the command window.
also, type whos to see the size of your data in memory.
With data of this size, if you're not careful, you will easily be out of memory.

댓글 수: 4

Isay
Isay 2014년 11월 10일
편집: Isay 2014년 11월 10일
1- just B increases and concatenate with A (in per-Loop)
2-when it crashes , matlab crashes too !! my computer didn't work and i should restart it !! so i didn't know Size(B), but i guess it's big!
Orion
Orion 2014년 11월 10일
편집: Orion 2014년 11월 10일
It's dangerous to stock that amount of data.
Some questions you need to think about :
Are you sure of your algorithm ? Do you need every component of B ? Can't you simplify it ?
How many iteration do you want to make ? it crash around 150, but what the total number ?
Depending of what you want to do, if you don't need a double precision, creates your data in single precision (if your data are integer, use int32), you could save a lot of memory.
>> A = rand(20);
B = single(A);
whos
Name Size Bytes Class Attributes
A 20x20 3200 double
B 20x20 1600 single
Isay
Isay 2014년 11월 11일
편집: Isay 2014년 11월 11일
the loop size is : 9000
in 112th loop , C(result of concatenate) was 18613*9000
memory in single mode was high too :(
Orion
Orion 2014년 11월 11일
According to what you say, you will never have sufficient memory to store your data.
You will be forced to code differently.
I ask again : Do you need every component of B ?
It's weird to have data of this size in an algorithm.
try to simplify it.
Also, one last possible hint. If your data is mostly filled with 0, you can use sparse.

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

Adam
Adam 2014년 11월 11일

0 개 추천

So you are concatenating B with A 150 times (and more)?
Is that really what you want to do? If your loop is of size 9000 is that not just one row of B chaanging each time in the loop and you want a single concatenation of
[A; B]
after the loop has completed, not every time round the loop?

댓글 수: 1

Isay
Isay 2014년 11월 11일
Hi
please read other comments.i said what i want

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

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2014년 11월 10일

댓글:

2014년 11월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by