Wrting binary data to text file
이전 댓글 표시
Hey everybody, I have some binary information, like a=[11110000 00001111 00000000 11111111], I want to write them to a text file. i tried with fprintf and fwrite but i couldn't! anybody has such a experience? Thanks a lot in advance. best.
댓글 수: 3
Walter Roberson
2014년 1월 9일
That first entry of "a": is it stored as decimal eleven million, one hundred and ten thousand? And size(a) is 1 x 4 ? Or is it stored as [1 1 1 1 0 0 0 0; 0 0 0 0 1 1 1 1; etc] and size(a) is 4 x 8? Or is it stored as {'11110000' '0000111' etc} ?
mahdi safarzadeh
2014년 1월 9일
mahdi safarzadeh
2014년 1월 9일
답변 (2개)
Huang Andong
2014년 1월 9일
0 개 추천
a=[11110000; 00001111; 00000000; 11111111]; dlmwrite('C:\Users\dell\Desktop\a.txt',a);
Walter Roberson
2014년 1월 9일
t = cellstr(dec2bin(a, 8));
fid = fopen('a.txt', 'wt');
fprintf(fid, '%s\n', t{:});
fclose(fid);
댓글 수: 3
mahdi safarzadeh
2014년 1월 14일
Walter Roberson
2014년 1월 14일
That is not going to work.
>> ['11111111' , '00000000' , '10101010']
ans =
111111110000000010101010
Remember, [] is concatenation for strings. {} is for string arrays.
mahdi safarzadeh
2014년 1월 14일
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!