代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Exameple 10.2 \n\n'); time_stamp = datestr(now, 31);
[wkd1, wkd2] = weekday(today, 'long');
fprintf(' Now is %20s, and it is %7s \n\n', time_stamp, wkd2);
%% ------------------------------------------------------------------------ clear; close all; % Example parameters
B = 2; N = 500000;
xn = (2*rand(1,N)-1); % Quantization error analysis
[H1, H2, Q, estat] = StatModelR(xn, B, N); % Compute histograms
H1max = max(H1); H1min = min(H1); % Max and Min of H1
H2max = max(H2); H2min = min(H2); % Max and Min of H2 Hf1 = figure('units', 'inches', 'position', [1, 1, 8, 6], ...
'paperunits', 'inches', 'paperposition', [0, 0, 6, 4], ...
'NumberTitle', 'off', 'Name', 'Exameple 10.2a B=2');
set(gcf,'Color','white');
TF = 10; subplot(2, 1, 1);
bar(Q, H1); axis([-0.5, 0.5, -0.001, 4/128]); grid on;
title('Normalized error e1 and e2 Histograms, B = 2');
xlabel('Normalized error e1'); ylabel('Distribution of e1 ', 'vertical', 'baseline');
set(gca, 'YTickMode', 'manual', 'YTick', [0, [1:1:4]/128] );
text(-0.45, 0.030, sprintf('SAMPLE SIZE N = %d', N));
text(-0.45, 0.025, sprintf(' ROUNDED TO B = %d BITS', B));
text(-0.45, 0.020, sprintf(' MEAN = %.4e', estat(1)));
text(0.10, 0.030, sprintf('MIN PROB BAR HEIGHT = %f', H1min)) ;
text(0.10, 0.025, sprintf('MAX PROB BAR HEIGHT = %f', H1max)) ;
text(0.10, 0.020, sprintf(' SIGMA = %f', estat(2))) ; subplot(2, 1, 2);
bar(Q, H2); axis([-0.5, 0.5, -0.001, 4/128]); grid on;
%title('Normalized error e2');
xlabel('Normalized error e2'); ylabel('Distribution of e2', 'vertical', 'baseline');
set(gca, 'YTickMode', 'manual', 'YTick', [0, 1:1:4]/128 );
text(-0.45, 0.030, sprintf('SAMPLE SIZE N = %d', N));
text(-0.45, 0.025, sprintf(' ROUNDED TO B = %d BITS', B));
text(-0.45, 0.020, sprintf(' MEAN = %.4e', estat(3)));
text(0.10, 0.030, sprintf('MIN PROB BAR HEIGHT = %f', H2min)) ;
text(0.10, 0.025, sprintf('MAX PROB BAR HEIGHT = %f', H2max)) ;
text(0.10, 0.020, sprintf(' SIGMA = %f', estat(4))) ;

  这里只写了B=2 的情况,B=6的类似。

运行结果:

上面给出了B=2和B=6两种情况下误差分布图。从第1张图看出,即使B=2的情况,量化误差采样序列也是独立的和均匀分布的。

《DSP using MATLAB》示例 Example 10.2的更多相关文章

  1. DSP using MATLAB 示例 Example3.10

    用到的性质 上代码: n = -5:10; x = rand(1,length(n)) + j * rand(1,length(n)); k = -100:100; w = (pi/100)*k; % ...

  2. DSP using MATlAB 示例Example2.10

    上代码 % noise sequence 1 x = [3, 11, 7, 0, -1, 4, 2]; nx = [-3:3]; % given signal x(n) [y,ny] = sigshi ...

  3. DSP using MATLAB 示例Example3.21

    代码: % Discrete-time Signal x1(n) % Ts = 0.0002; n = -25:1:25; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*a ...

  4. DSP using MATLAB 示例 Example3.19

    代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signa ...

  5. DSP using MATLAB示例Example3.18

    代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Continuous-time Fou ...

  6. DSP using MATLAB 示例 Example3.13

    上代码: w = [0:1:500]*pi/500; % freqency between 0 and +pi, [0,pi] axis divided into 501 points. H = ex ...

  7. DSP using MATLAB 示例 Example3.12

    用到的性质 代码: n = -5:10; x = sin(pi*n/2); k = -100:100; w = (pi/100)*k; % freqency between -pi and +pi , ...

  8. DSP using MATLAB 示例 Example3.11

    用到的性质 上代码: n = -5:10; x = rand(1,length(n)); k = -100:100; w = (pi/100)*k; % freqency between -pi an ...

  9. DSP using MATLAB 示例Example3.8

    代码: x = rand(1,11); n = 0:10; k = 0:500; w = (pi/500)*k; % [0,pi] axis divided into 501 points. X = ...

  10. DSP using MATLAB 示例Example3.7

    上代码: x1 = rand(1,11); x2 = rand(1,11); n = 0:10; alpha = 2; beta = 3; k = 0:500; w = (pi/500)*k; % [ ...

随机推荐

  1. php5.4一下 json_encode 不转义中文

    转载地址:http://www.nowamagic.net/php/php_FunctionJsonEncode.php 在 php 中使用 json_encode() 内置函数(php > 5 ...

  2. UVA10529 Dumb Bones

    UVA10529 Dumb Bones go to solution 设$f[i]$表示叠$i$个的骨牌的期望 $O(n)$做法 #include<iostream> #include&l ...

  3. object类之toString方法

    object是所有类的基类 如果没有使用extends关键字指明其基类,则默认基类为object类 public class Person{ ........ } 等价于: public class ...

  4. [BZOJ2834]回家的路

    Description Input Output Sample Input 2 1 1 2 1 1 2 2 Sample Output 5   思路还是很简单的,然而最短路打错各种对拍各种调了一早上 ...

  5. CentOS6安装Pyhon3

    一,从官方下载Python3.6 [root@linux-node1 src]# pwd /usr/local/src [root@linux-node1 src]# wget https://www ...

  6. LA 3268 号码簿分组(最大流+二分)

    https://vjudge.net/problem/UVALive-3268 题意: 有n个人和m个组.一个人可能属于很多组.现在请你从某些组中去掉几个人,使得每个人只属于一个组,并使得人数最多的组 ...

  7. Codeforces Round #275 (Div. 2) A,B,C,D

    A. Counterexample time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  8. Java如何用一行代码初始化ArrayList

    参考链接: 1.Initialization of an ArrayList in one line 2.java怎么用一行代码初始化ArrayList

  9. activemq、rabbitmq、kafka原理和比较

    一.activemq 虽然是java写的消息队列,但是提供Java, C, C++, C#, Ruby, Perl, Python, PHP各种客户端,所以语言上是没什么问题的.配置和使用,基本上是j ...

  10. Mac上安装配置和简单使用PostgreSQL(仍然很不懂)

    因为想要使用推荐的rails-template.需要使用postgres.并初始化了一个用户postgres,密码是postgres.( e.g. $ createuser -d postgres ) ...