concatenating matrices
Mostra commenti meno recenti
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 Commenti
per isakson
il 14 Mag 2012
How large is your file? r=24000 what's that?
Walter Roberson
il 14 Mag 2012
rows and columns maybe?
Risposte (4)
Walter Roberson
il 14 Mag 2012
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
il 14 Mag 2012
0 voti
2 Commenti
Oleg Komarov
il 14 Mag 2012
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
il 14 Mag 2012
Titus Edelhofer
il 14 Mag 2012
0 voti
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
il 14 Mag 2012
0 voti
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!