How to get bits in text file to a column vector in matlab

2 ビュー (過去 30 日間)
zeno diac
zeno diac 2017 年 1 月 8 日
コメント済み: zeno diac 2017 年 1 月 9 日
I have a .txt file containing binary numbers, grouped in 4-bits like so: "0010 1100 1111 0011" I would like to use them as binary inputs for modulation. The function is defined in Matlab as " txSig = qammod(data,M,'InputType','bit','UnitAveragePower',true);" and it is the "data" array that must be a column vector of bits. Copy-pasting the binary in Matlab, makes it a string. But how to get it now in a column vector without ridding the leading zeros during a conversion process is the question... please help

採用された回答

Jan
Jan 2017 年 1 月 8 日
Str = '0010 1100 1111 0011';
Str(issapce(Str)) = [];
Bits = uint8(Str(:) == '1');
Not "Bits" is an UINT8 column vector of 1s and 0s. Perhaps you mean this by a vector of bits.
  1 件のコメント
zeno diac
zeno diac 2017 年 1 月 9 日
Str = '0010 1100 1111 0011'; Str(isspace(Str)) = []; Bits = uint8(Str(:) == '1');
Works fine, thank you

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStandard File Formats についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by