How to Convert an Input Sine Wave into an 8-Bit Digital Signal

조회 수: 19 (최근 30일)
Ryan
Ryan 2013년 5월 11일
댓글: Walter Roberson 2022년 10월 21일
Hi, I am working on a project and I am not sure how to convert the input signal from an analog to an 8-bit digital signal. Here is my code:
t = [0:1:4000]; % Number of Samples
fs = 4500; % Sampled Frequency
Input = sin((2*pi*t)/fs); % Analog Sine Wave
subplot(2,1,1)
plot(Input) % Analog Sine Wave Plot
grid on
My question is how to convert this sine wave sampled at 4500 Hz into a digital 8-bit signal.
  댓글 수: 4
Image Analyst
Image Analyst 2013년 5월 11일
편집: Image Analyst 2013년 5월 11일
And not analog either. But it is in a digital computer so it's quantized/digitized to the smallest amount that the computer can handle (is that eps?) Perhaps you have a different definition of digitized than me. Because he is taking samples at certain times, the sine wave output will also take on certain discrete values, not uniformly spaced along the y axis. But even though his signal may take on only 4001 discrete values, it is still digitized at 64 bits. Of course he can convert that to 8 bits (256 discrete values) if he wants. An analog signal would be continuous, like the voltage you'd get from measuring an electronic circuit (ignoring the quantization you get at the charge of a single electron). That said, I'm just being picky about the definitions - I actually think he really did want your answer.
Azzi Abdelmalek
Azzi Abdelmalek 2013년 5월 11일
편집: Azzi Abdelmalek 2013년 5월 11일
The real ADC (Analog to Digital Converter) works with 8,10,12 or 16 bits, rarely with 32 bits (It depends on the sample frequency wich causes noise). We can consider that a digitized number at 64 bits, with a very small sample time, represent an analog signal, which can be sampled and quantized again at 8 bits for example.
The Simulink simulate continuous and discrete systems, both are represented by 64 bits digitized data.

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

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 5월 11일
편집: Azzi Abdelmalek 2013년 5월 11일
t = [0:1:4000];
fs = 4500;
Input1 = sin((2*pi*t)/fs);
quant=max(Input1)/(2^7-1)
y=round(Input1/quant)
signe=uint8((sign(y)'+1)/2)
out=[signe dec2bin(abs(y),7)] % The first bit represents the sign of the number
  댓글 수: 2
PUSHPAK SAKHALA 17MCD0019
PUSHPAK SAKHALA 17MCD0019 2018년 8월 14일
CAN U EXPLAIN THIS CODE PLEASE SINCE I AM NEW TO MATLAB?
Walter Roberson
Walter Roberson 2022년 10월 21일
@Yash Doshi what leads you to say that this Answer is incorrect ?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Modulation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by