how to convert analog signal to bit stream

조회 수: 16 (최근 30일)
Murali Krishna AG
Murali Krishna AG 2021년 8월 3일
답변: Walter Roberson 2021년 8월 3일
I generate a analog signal cos(2pi*f*t), fs is sampling frequency and I denotes quantization levels. How to convert the analog signal to bit stream
  댓글 수: 2
Walter Roberson
Walter Roberson 2021년 8월 3일
How do you generate the analog signal?
Murali Krishna AG
Murali Krishna AG 2021년 8월 3일
t=0:1:30;
f=1000;
x=cos(2*pi*f*t)

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2021년 8월 3일
That is not an analog signal. An analog signal is created by outputing to a hardware device. What you have is a digital signal.
Your description said I denotes quantization levels. If so then
I = linspace(-1,1,32);
t = linspace(0,1,75);
f = 17;
x = cos(2*pi*f*t);
plot(t, x)
binnumber = discretize(x, I) - 1;
binnumber(1:10)
ans = 1×10
30 17 0 9 29 24 4 3 23 29
num_bits = ceil(log2(length(I)))
num_bits = 5
as_char_binary = dec2bin(binnumber, num_bits);
as_char_binary(1:5,:)
ans = 5×5 char array
'11110' '10001' '00000' '01001' '11101'
binary_stream = reshape((as_char_binary - '0').',1,[]);
stairs(binary_stream); ylim([-.1 1.1]); xlim([0 50])

카테고리

Help CenterFile Exchange에서 Periodic Waveform Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by