Anyone can please help me with my matlab program to quatize x(t)
Show older comments
quatize x(t) using 4 bits to obtain and plot the quantized signal xq, assuming the signal range is between -5 and 5 volts
the error: 'biquant' undefined near line 11 column 20, but i don't know how to solve it
clear all; close all
disp("Generate 0.02-second sine wave of 100 Hz and Vp=5");
fs = 8000; % Sampling rate
T = 1/fs; % Sampling interval
t = 0:T:0.02; % Duration of 0.02 second
sig = 4.5*sin(2*pi*100*t); % Generate sinusoids
bits = input("input number of bits =>");
lg = length(sig); % Length of signal vector sig
for x = 1:lg
[Index(x), pq] = biquant(bits, -5,5, sig(x)); % Output quantized index
end
% transmitted
% received
for x=1:lg
qsig(x) = biqtdec(bits, -5,5, Index(x)); % Recover the quantized value
end
qerr = qsig-sig; % Calculate quantized error
stairs(t,qsig); hold % Plot signal in staircase style
plot(t,sig); grid; % Plot signal
xlabel("Time (sec.)"); ylabel("Quantized x(n)")
disp("Signal to noise ratio due to quantization noise")
snr(sig,qsig);
Accepted Answer
More Answers (2)
Aissa blk
on 12 Feb 2021
0 votes
le lien que vouz avez donner ne fonctionne pas (pour telecharger fonction bitquant)
clear all; close all
disp('Generate 0.02-second sine wave of 100 Hz and Vp=5');
fs=8000; % Sampling rate
T=1/fs; % Sampling interval
t=0:T:0.02; % Duration of 0.02 second
sig = 4.5*sin(2*pi*100*t); % Generate sinusoids
bits = input('input number of bits =>');
lg = length(sig); % Length of signal vector sig
for x=1:lg
[sig(x) pq] = biquant(bits, -5.5, sig(x)); % Output quantized index
end
% transmitted
% received
for x=1:lg
qsig(x) = biqtdec(bits, -5,5, Index(x)); % Recover the quantized value
end
qerr = qsig-sig; % Calculate quantized error
stairs(t,qsig); hold % Plot signal in staircase style
plot(t,sig); grid; % Plot signal
xlabel('Time (sec.)'); ylabel('Quantized x(n)')
disp('Signal to noise ratio due to quantization noise')
snr(sig,qsig);
Categories
Find more on Signal Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!