printf - <MATLAB> How can I save huge data to .txt file? -


i made 865850 4464 matrix.

then need save .txt file.

for that, use fprintf, met hard obstacle....

there 4464 columns. how can designate formatspec?

they integers.

now know 1 way...

fprintf(fid, '%10d %10d.....%10d', zeros); (4464times..)

is way save them?

thank you~!!

clear all; close all;  loop = 1; zeros = zeros(15000, 4464);  fileid = fopen('data2.txt','r');  while loop < 4200     data = fscanf(fileid, '%d %d %d:%d %d\n', [5, 100000]);     data = data';     dataa = data(:,1);     datab = data(:,2);     datac = data(:,3);     datad = data(:,4);     datae = data(:,5);       m=1:100000         r = dataa(m);         c = ((datab(m)-1)*24*6 + datac(m)*6 + datad(m))+1;         zeros(r,c) = datae(m);                 end     n=1:4464         zeros1{n}=zeros(:, n);         fileid2 = fopen('result.txt','a');         fprintf(fileid2, '%10d %10d\n ', zeros1{1}, zeros1{2});     end    fclose(fileid2);    loop = loop + 1; 

end

don't use printf whole row. use csv export, or iterate on each element of each row , print isolatedly.

i add data of size, textual storage bad idea. no 1 ever open in text editor , think "oh, practical". have bad time carrying around hundreds of megabytes of unnecessary file size. use savemat methods store data if plan open in matlab, or use binary format, example doing fwrite on data file sensible binary representation of numbers.


Popular posts from this blog