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
2012-5-14
How large is your file? r=24000 what's that?
Walter Roberson
2012-5-14
rows and columns maybe?
回答(4 个)
Walter Roberson
2012-5-14
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
2012-5-14
0 个投票
2 个评论
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
2012-5-14
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
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!