How to convert sinewave(any signal) into 8bit binary in Simulink?

7 ビュー (過去 30 日間)
Ram
Ram 2017 年 8 月 9 日
回答済み: Eric Ogier 2017 年 8 月 31 日
Hi all, I am trying to convert a sinewave into binary data by using the Sine wave, Quantizer, limiter, convert blocks. but i am unable to visualise the 8 bits in output.(getting only 1 or 0 in display). Kindly help me in this regard. I want to get all samples data in binary format and then replacing or randomly changing into 0's to 1's.
Thanks in advance.

回答 (2 件)

Jon Lobo
Jon Lobo 2017 年 8 月 9 日
Did you try converting to a uint8 data type? You will have to fix the scaling as it will be 0 to 255.
  2 件のコメント
Ram
Ram 2017 年 8 月 9 日
Yes, I use unit8 type with 255levels
Ram
Ram 2017 年 8 月 17 日
編集済み: Ram 2017 年 8 月 17 日
i placed SW,qunatizer,limiter, integer to bit conversion block and display block. Should i write any function code (dec2bin) or its enough to use integer to bit converter block?

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


Eric Ogier
Eric Ogier 2017 年 8 月 31 日
Hello,
Sorry for the delayed response. What about an "Embedded MATLAB function" block calling this kind of code (1 input, 8 outputs) ?
function [b7,b6,b5,b4,b3,b2,b1,b0] = bitgetuint8(Signal)
B = boolean(bitget(uint8(Signal),8:-1:1,'uint8'));
b0 = B(1);
b1 = B(2);
b2 = B(3);
b3 = B(4);
b4 = B(5);
b5 = B(6);
b6 = B(7);
b7 = B(8);
end

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by