this is the code that i want to run, but got problem Undefined function or variable 'QFix'
Mostrar comentarios más antiguos
close all; clc;
% Example Parameters
B = 6; %# of fractional bits
N = 100000; % # of samples
xn = (2*rand(1,N)-1); % Input sequence - Uniform Distribution
a = 0.9; % Filter parameter
Xm = 1-abs(a); % Scaling factor
% Local variables
bM = 7; DbM = 2^bM; % bin parameter
BB = 2^B; % useful factor in quantization
M = round(DbM/2); % Half number of bins
bins = [-M+0.5:1:M-0.5]; % Bin values from -M to M
Q = bins/DbM; % Normalized bins
YTN = 2^(-bM); % Ytick marks interval
YLM = 4*YTN; % Yaxis limit
% Quantize the input and the filter coefficients
xn = QFix(Xm*xn,B,'round','satur'); % Scaled Input quant to B bits
a = QFix(a,B,'round','satur'); % a quantized to B bits
% Filter output without multiplication quantization
yn = filter(1,[1,-a],xn); % output using filter routine
% Filter output with multiplication quantization
yq = zeros(1,N); % Initialize quantized output array
yq(1) = xn(1); % Calculation of the first sample yq(1)
for I = 2:N;
A1Y = QFix(a*yq(I-1),B,'round','satur'); % Quantization of a*y(n-1)
yq(I) = QFix(A1Y+xn(I),B,'round','satur'); % I-th sample yq(I)
end
% Output Error Analysis
en = yn-yq; % Output error sequence
varyn = var(yn); varen = var(en); % Signal and noise power
eemax = max(en); eemin = min(en); % Maximum and minimum of the error
enmax = max(abs([eemax,eemin])); % Absolute maximum range of the error
enavg = mean(en); enstd = std(en); % Mean and std dev of the error
en = round(en*(2^bM)/(2*enmax)+0.5); % Normalized en (integer between -M & M)
en = sort([en,-M:1:(M+1)]); %
H = diff(find(diff(en)))-1; % Error histogram
H = H/N; % Normalized histogram
Hmax = max(H); Hmin = min(H); % Max and Min of the normalized histogram
% Output SNRs
SNR_C = 10*log10(varyn/varen); % Computed SNR
SNR_T = 6.02 + 6.02*B + 20*log10(Xm); % Theoretical SNR
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Frequency Transformations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!