フィルターのクリア

Modulate a sine wave after quantizing it

3 ビュー (過去 30 日間)
jessica david
jessica david 2011 年 3 月 20 日
編集済み: Image Analyst 2020 年 11 月 11 日
Help! I am trying to modulate a sine wave after quantizing it, but keep getting an error. =================================
t = [0:.1:2*pi]; % Times at which to sample the sine function
sig = sin(t); % Original signal, a sine wave
partition = [-1:2/15:1]; % Length 15, to represent 16 intervals
codebook = [-1.2:2/15:1]; % Length 16, one entry for each interval
[index,quants] = quantiz(sig,partition,codebook); % Quantize.
plot(t,sig,'x',t,quants,'.')
legend('Original signal','Quantized signal');
axis([-.2 7 -1.2 1.2])
M=16;
y=qammod(quants,M)
==============
??? Error using ==> qammod at 39
Elements of input X must be integers in the range [0, M-1].
>>
I checked the max and min value of quants and found it to be:
>> max(quants)= 0.8000
>> min(quants)= -1
Is there some way i can scale quants so I get in the specified range?

採用された回答

Walter Roberson
Walter Roberson 2011 年 3 月 20 日
No. You need to fix your codebook. Your codebook must be integers from 0 to M-1 .
  2 件のコメント
jessica david
jessica david 2011 年 3 月 21 日
yes, it works that time, but then the values of index = values of quants, i think some info is getting lost in this process. i used codebook = [0:1:15]
Walter Roberson
Walter Roberson 2011 年 3 月 21 日
You haven't read the quantiz documentation carefully enough, which has been the source of your problem for several days. The last quantization index will only be used if the signal *exceeds* the last partition parameter, which has never been the case in your calculation as your maximum signal value _equals_ the last partition parameter.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSource Coding についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by