Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: saving huge char arrays
Replies: 4   Last Post: Apr 17, 2013 3:07 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bruno Luong

Posts: 8,776
Registered: 7/26/08
Re: saving huge char arrays
Posted: Apr 17, 2013 3:07 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

array = char('A'+(floor('Z'-'A'+1)*rand(10000,17)));

tic
fid = fopen('test1.txt','wt');
for m=1:length(array)
fprintf(fid,'%s\r\n',array(m,:));
end
fclose(fid);
t = toc / length(array) * 3^17;
fprintf('predict time = %g s\n', t); % 4282.37 s

tic
b = [uint8(array) repmat([13 10],size(array,1),1)].';
fid = fopen('test2.txt','wb');
fwrite(fid,b);
fclose(fid);
t = toc / length(array) * 3^17;
fprintf('predict time = %g s\n', t); % 39.9248 s

% Bruno



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.