concatenating matrices

I have 1 large correlation file with 24000x24000 elements. In order to be able to import into matlab I created 3 sub-matrices using the following-
file = ('text.txt');
r = 24000;
c = 24000;
fid = fopen(file,'r');
a = r*c;
m = textscan(fid,'%f',a);
b = m{1}(4:6403); %needed to exclude the first 3 elements
mat1 = reshape(b,80,80); %[similarly for mat2 and mat3].
Now I need to combine these matrices into one large matrix; how do I do that?
-thanks.
[Edited, code formatted, Jan S]

댓글 수: 2

per isakson
per isakson 2012년 5월 14일
How large is your file? r=24000 what's that?
Walter Roberson
Walter Roberson 2012년 5월 14일
rows and columns maybe?

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

답변 (4개)

Walter Roberson
Walter Roberson 2012년 5월 14일

0 개 추천

It is not clear what the rule is for mat2 and so on. Are you excluding the first 3 elements of each group of 6403? If so then 24000*24000 is the wrong size to read to get a complete final matrix. Even if the rule is to skip the first 3 only and to take 80x80 after that, r*c is the wrong number of elements to read.
What is the rule for combining into one large matrix? 80 rows total, and 80+80+80+... columns? 3D, 80 x 80 x however-many?
reshape(m{1}(4:end), [80, 80, r*c-3])
would be one interpretation.
veeus18
veeus18 2012년 5월 14일

0 개 추천

Hi, yes, r=24000 rows and c=24000 columns(probably a little more than that). I am working on a 64-bit m/c with 8gb ram, but Matlab can't read the data when I import it as one large text file. I only need to exclude the very first 3 elements from my data file. My end matrix needs to be 24000x24000. Hence trying to see if I can break it down. But then I don't know how to put it back. I can upload the text file if that would help! Thanks for any suggestions.

댓글 수: 2

Oleg Komarov
Oleg Komarov 2012년 5월 14일
you're repeating yourself w/o giving additional information.
How did you break the 24000 by 24000 matrix?
What are the sizes of mat1, mat2, mat3?
Did YOU break the big matrix?
veeus18
veeus18 2012년 5월 14일
I just picked an arbitrary number for mat1, mat2, mat3..I figured if I read in a 4000x4000 matrix first, I would need to do it 6 times(6 sub-matrices), if I read in 6400x6400, then read it in 4 sub-matrices..etc..maybe it is not the best way to do it..but that is why I am here..

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

Titus Edelhofer
Titus Edelhofer 2012년 5월 14일

0 개 추천

Hi Maithili,
just a warning: the final matrix will need 24000*24000*8/(1024^3)GB, so approx 4.3 GB of memory. Should work but you better make sure you don't copy it around ...
Why don't you read your text.txt in chunks? Preallocate a large (24000x24000) matrix, and read in a loop 500 lines (about 90MByte), put it into your matrix and continue. textscan allows a max number of elements to be read.
Titus
veeus18
veeus18 2012년 5월 14일

0 개 추천

Thanks, but not sure I know how to preallocate and read in a loop...

카테고리

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

질문:

2012년 5월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by