write an array of 8 bit binary to text file?

11 ビュー (過去 30 日間)
darren Clipson
darren Clipson 2021 年 6 月 26 日
編集済み: Scott MacKenzie 2021 年 6 月 26 日
Hello again,
second question from me today, albeit not quite as complex as the previous.
I have created an array of 8 bit binary groups in the format: '195 x 8 char array'
My intention is to output these to a file, so a second remote user can import them in the same format. Currently, using the formatting operators, I am unable to do so. The closest I have come to achieving my goal is a single concananated string.
I want to write the 8 bit binary groups to a file called 'ENCODE OUTPUT', the binary groups are arranged vertically as follows:
'00101111'
'00101111'
'01110010'
and so on...
My code is as follows:
fid =fopen('ENCODE OUTPUT.txt', 'wt' );
fprintf(fid, '%s,8\n', binX);
fclose(fid);
binX is the variable that contains the entire binary data.
Please accept my apologies if my terminology is off, and thank you for any assistance you can offer.

採用された回答

Scott MacKenzie
Scott MacKenzie 2021 年 6 月 26 日
You don't need fopen, fprintf, or fclose. A simple script like this will do the trick:
binX = ['00101111'; '00101111'; '01110010'];
writematrix(binX, 'yourfile.txt');
  4 件のコメント
darren Clipson
darren Clipson 2021 年 6 月 26 日
That is a super helpful and detailed reply Scott. Thank you so much for taking the time to help here.
Scott MacKenzie
Scott MacKenzie 2021 年 6 月 26 日
You're welcome. Glad to help. Good luck.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by