1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| M = int8(255*rand(500,100)-127);
tic
% Ecriture ascii
fid = fopen('M.txt','wt');
fprintf(fid,'% d',M.');
fclose(fid);
toc
tic
% Ecriture binaire
fid = fopen('M.bin','w');
fwrite(fid,M.','int8');
fclose(fid);
toc
tic
% Lecture ascii
fid = fopen('M.txt','rt');
Mascii = fscanf(fid,'%d',[100,500]).';
fclose(fid);
toc
tic
% Lecture binaire
fid = fopen('M.bin','r');
Mbinaire = fread(fid,[100,500],'*int8').';
fclose(fid);
toc
whos
all(Mascii(:) == Mbinaire(:)) |
Partager