Quantization Error Using Matlab
Contents |
Search All Support Resources Support Documentation MathWorks Search MathWorks.com MathWorks Documentation Support Documentation Toggle navigation Trial Software Product Updates Documentation plot quantization error matlab Home Fixed-Point Designer Examples Functions and Other Reference Release Notes PDF matlab quantization error Documentation Fixed-Point Design for MATLAB Code Fixed-Point Functions Math Statistics Fixed-Point Designer Functions errmean On this matlab code for quantization of sine wave page Syntax Description Examples See Also errmeanMean of quantization error Syntaxm = errmean(q)
Descriptionm = errmean(q) returns the mean of a uniformly distributed random quantization error that arises matlab quantizer from quantizing a signal by quantizer object q. Note The results are not exact when the signal precision is close to the precision of the quantizer.ExamplesFind m, the mean of the quantization error for quantizer q:q = quantizer; m = errmean(q) m = -1.525878906250000e-005 Now compare m to m_est, the sample mean from a
Quantization In Matlab Code
Monte Carlo experiment:r = realmax(q); u = 2*r*rand(1000,1)-r; % Original signal y = quantize(q,u); % Quantized signal e = y - u; % Error m_est = mean(e) % Estimate of the error mean m_est = -1.519507450175317e-005See Alsoerrpdf | errvar | quantize Was this topic helpful? × Select Your Country Choose your country to get translated content where available and see local events and offers. Based on your location, we recommend that you select: . You can also select a location from the following list: Americas Canada (English) United States (English) Europe Belgium (English) Denmark (English) Deutschland (Deutsch) España (Español) Finland (English) France (Français) Ireland (English) Italia (Italiano) Luxembourg (English) Netherlands (English) Norway (English) Österreich (Deutsch) Portugal (English) Sweden (English) Switzerland Deutsch Français United Kingdom (English) Asia Pacific Australia (English) India (English) New Zealand (English) ä¸å›½ (简体ä¸æ–‡) 日本 (日本語) í•œêµ (í•œêµì–´) See all countries Trial Software Product Updates Fixed-Point Designer Documentation Examples Functions and Other Reference Release Notes PDF Documentation Othe
Support Support Newsreader MathWorks Search MathWorks.com MathWorks Newsreader Support MATLAB Newsgroup MATLAB Central Community Home MATLAB Answers File Exchange Cody Blogs Newsreader Link Exchange ThingSpeak Anniversary Home Post A New
Quantization Error Formula
Message Advanced Search Help MATLAB Central Community Home MATLAB Answers File Exchange how to do quantization in matlab Cody Blogs Newsreader Link Exchange ThingSpeak Anniversary Home Post A New Message Advanced Search Help Trial software A/D Quantization sqnr error- reconciling Subject: A/D Quantization error- reconciling From: Kris Kris (view profile) 1 post Date: 27 Jul, 2010 19:27:06 Message: 1 of 1 Reply to this message Add author to My Watch https://www.mathworks.com/help/fixedpoint/ref/errmean.html List View original format Flag as spam I am trying to simulate and understand the Signal to Quantization Noise Ratio (SQNR) for a linear ADC. This file will later be expanded to include noise shaping etc and also to choose the converter of choice. Here is my question- 1) I have calculated the Noise power using the variance of a uniform pdf which is https://www.mathworks.com/matlabcentral/newsreader/view_thread/287920 Q^2/12, where Q is the quantization level. This noise power when used with Signal power to compute SQNR turns out ok according to the standard formula 6.02 N + 1.76 dB. This is called AvgNoisePowerIdeal in the sim below 2) When i used the statistics of the quantization error to compute quantization noise power the SQNR turns out higher. This noise power is called AvgNoisePower below in the sim. I am unable to reconcile difference between the two. any help would be helpful. thanks! The full .m file is below close all clear all clc A = 0.7; % Peak amplitude in Volts f = 1000; %Fundamental Frequency in Hz Fs = 10000 ; %Sampling frequency in Hz Ts = 1/Fs; n = 5; % Simulation length in Seconds n = n/Ts;% Simulation length in number of sampling instants NFFT = 2^nextpow2(n);%vector length for FFT DC = 0.0; TimeVector = (0:n-1)*Ts; %AWGN = randn(size(TimeVector)); AWGN = zeros(size(TimeVector)); Signal = DC + A*sin(2*pi*f*TimeVector) + AWGN; FreqVector = linspace(-Fs/2,Fs/2,NFFT); %Scaling of FFT so the result is independent of n a = fft(Signal,NFFT)./n; %TWO SIDED MAGNITUDE SPECTRUM - log scale figure(2) plot(FreqVector,20*log10(fftshift(ab
very similar. As the number of bits increased, so did the SQNR as we would http://dluong1.bol.ucla.edu/swarthmore/e71/lab3/lab3.htm expect. The graphs and the results in the table are generated using the Matlab script. Note: X denotes the original signal and xd is the quantized signal for all graphs in this lab. Bits Experimental SQNR (dB) Theoretical SQNR (dB) Mean Quantization Noise Variance in Quantization Noise 4 26.201 25.84 quantization error 2.89E-02 1.20E-03 8 49.7767 49.92 1.98E-03 5.17E-06 12 74.8614 74.00 1.07E-04 1.63E-08 16 98.0608 98.08 7.59E-06 7.85E-11 t=0:0.1:4*pi; fprintf('Exp\t\tTh\t\tMean\t\tVar\n'); for n=4:4:16, x=sin(t); xd=round(x*2^(n-1))/2^(n-1); error=xd-x; error_mean=mean(abs(error)); error_variance=var(error); figure; plot(t,x,t,xd,t,error) legend('x','xd','error') SQNR=10*log10(sum(x.^2)/sum(error.^2)); SQNR_eqn=1.76+6.02*n; title(strcat(num2str(n),' bits. SQNR=',num2str(SQNR),' dB.')) fprintf('%0.4f\t%0.4f\t%0.3e\t%0.3e\n',SQNR,SQNR_eqn,error_mean,error_variance); end 2. Quantization quantization in matlab of Sinusoidal Signal (truncating to integer bit) The experimental SQNR was always lower than the theoretical value. This was expected because instead of rounding the data as in part 1, we truncated, which leads to less accurate quantization of the signal and a lower SQNR. Bits Experimental SQNR (dB) Theoretical SQNR (dB) Mean Quantization Noise Variance in Quantization Noise 4 19.3759 25.84 6.54E-02 1.49E-03 8 44.0569 49.92 3.82E-03 5.06E-06 12 68.1629 74 2.29E-04 2.38E-08 16 91.9115 98.08 1.56E-05 7.97E-11 t=0:0.1:4*pi; fprintf('Exp\t\tTh\t\tMean\t\tVar\n'); for n=4:4:16, x=sin(t); xd=floor(x*2^(n-1))/2^(n-1); error=xd-x; error_mean=mean(abs(error)); error_variance=var(error); figure; plot(t,x,t,xd,t,error) legend('x','xd','error') SQNR=10*log10(sum(x.^2)/sum(error.^2)); SQNR_eqn=1.76+6.02*n; title(strcat(num2str(n),' bits. SQNR=',num2str(SQNR),' dB.')) fprintf('%0.4f\t%0.4f\t%0.3e\t%0.3e\n',SQNR,SQNR_eqn,error_mean,error_variance); end 3. Quantization of Gaussian Noise Signal As expected, the SQNR tends to increase with the number of bits used to quantize the signal. Bits Experimental SQNR (dB) Mean Quantization Noise Variance in Quantization Noise 4 29
be down. Please try the request again. Your cache administrator is webmaster. Generated Tue, 25 Oct 2016 00:42:43 GMT by s_wx1196 (squid/3.5.20)