How to quantise a sin wave with amplitude between -1 to 1?
1 回表示 (過去 30 日間)
古いコメントを表示
I have to quantise a continuous sin wave into a 16 bit signal and obtain the vector of the quantised signals in the binary form? How to get the binary of a decimal number which might be negative. Can anyone provide me with the code snippet for that?
0 件のコメント
採用された回答
Azzi Abdelmalek
2014 年 2 月 7 日
ts=0.01 % sample time
t=0:ts:10; % time vector
y=sin(t); % your signal
pas=(1-(-1))/(2^15-1) % quantization interval
ye=round(y/pas)
s=sign(ye')
s(s<=0)=0
yq=[num2str(s) dec2bin(abs(ye))] % use the first bit to define positive and negative numbers
2 件のコメント
Azzi Abdelmalek
2014 年 2 月 9 日
Sarah, if you have another question, post a new one and make it as clear as possible
その他の回答 (1 件)
Walter Roberson
2014 年 2 月 7 日
編集済み: Walter Roberson
2014 年 2 月 7 日
dec2bin(typecast(int16(floor(sin(t) * 32767)), 'uint16'), 16) - '0'
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!