From: Leah Magalang on
clear all; close all
disp('Generate 0.02-second sinewave of 100 Hz and Vp=5');
fs = 8000; %sampling rate
T = 1/fs; %sampling interval
t = 0:T:0.02;
sig = 4.5*sin(2*pi*100*t);
bits = input('input number of bits=>');
lg = length(sig);
for x = 1:lg
[Index(x)pq] = biquant(bits,-5,5,sig(x)); %Output the quantized index
end
%transmitted
%recieved
for x = 1:lg
qsig(x) = biqtdec(bits,-5,5,Index(x));
end
qerr = qsig - sig; %Calculate the quantized errors
stairs(t,qsig);hold %Plot the signal in a staircase style
plot(t,sig);grid;
xlabe('Time (sec.)');ylabel('quantized x(n)')
disp('Signal to noise power ration due to quantization')
snr(sig,qsig);



There is error in the Index, and I don't know how to correct it.. pls help me >>>.<<<
From: Ross W on
"Leah Magalang" <leah_cim_pup(a)yahoo.com> wrote in message <i42pps$r47$1(a)fred.mathworks.com>...
> clear all; close all
> disp('Generate 0.02-second sinewave of 100 Hz and Vp=5');
> fs = 8000; %sampling rate
> T = 1/fs; %sampling interval
> t = 0:T:0.02;
> sig = 4.5*sin(2*pi*100*t);
> bits = input('input number of bits=>');
> lg = length(sig);
> for x = 1:lg
> [Index(x)pq] = biquant(bits,-5,5,sig(x)); %Output the quantized index
> end
> %transmitted
> %recieved
> for x = 1:lg
> qsig(x) = biqtdec(bits,-5,5,Index(x));
> end
> qerr = qsig - sig; %Calculate the quantized errors
> stairs(t,qsig);hold %Plot the signal in a staircase style
> plot(t,sig);grid;
> xlabe('Time (sec.)');ylabel('quantized x(n)')
> disp('Signal to noise power ration due to quantization')
> snr(sig,qsig);
>
>
>
> There is error in the Index, and I don't know how to correct it.. pls help me >>>.<<<

Hi

[Index(x)pq] is missing a comma. It should be
[Index(x),pq]

Ross