How to convert text file to asci code ?

I need to convert text file to binary ascii code to use in M-ASK modulation ? can any one help me ?

回答 (2 件)

Vimal Rathod
Vimal Rathod 2020 年 5 月 5 日

0 投票

Hi,
Once you read the text data from your file, you can convert text to binary by using dec2bin function.
a = dec2bin("Some String");
The variable "a" will have the binary converted value.
For reading from text files you could refer to the following links of different read functions
Hope this helps.

1 件のコメント

Walter Roberson
Walter Roberson 2020 年 5 月 5 日
dec2bin() will not work on string objects. It will work on character vectors (but remember that characters can have more than 8 significant bits.)

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

Walter Roberson
Walter Roberson 2020 年 5 月 5 日

0 投票

fid = fopen('FileNameGoesHere', 'r');
file_bytes = fread(fid, [1 inf], '*uint8');
fclose(fid);
%if needed
file_bits = reshape( (dec2bin(filebytes, 8) - '0').', 1, []);
file_bits would be a vector of 0 and 1 values.

カテゴリ

ヘルプ センター および File ExchangeData Type Conversion についてさらに検索

質問済み:

2020 年 5 月 2 日

コメント済み:

2020 年 5 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by