storing binary data as .txt file and as binary data
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
i have a bunch of numbers x=[1:1:100]; to convert them to binary i used y=dec2bin(x,8); how do i store this "y" converted data as a .txt file? i need the information stored as binary data. what there options are there?
and is there a format where i can store the x numbers as a binary numbers?
0 Commenti
Risposte (2)
Thomas
il 8 Mag 2012
You could also try
% this will show the pretty output formatted file..
x=[1:1:100];
y=dec2bin(x,8);
new=cellstr(y);
fileID = fopen('exp.txt','w');
fprintf(fileID,'%s\n',new{:});
fclose(fileID)
0 Commenti
Walter Roberson
il 8 Mag 2012
fid = fopen('YourOutputFile.txt', 'wt');
fwrite(fid, y);
fclose(fid);
There is no fprintf() format that takes decimal numbers as input and writes out strings of '0' and '1'. Strings of '0' and '1' as produced by dec2bin() is not called "binary" in traditional computer programming. "binary" in traditional computer programming always refers to a numeric format, not to a string format.
0 Commenti
Vedere anche
Categorie
Scopri di più su Data Type Conversion in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!