代码:

%% ------------------------------------------------------------------------
%% 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. zoj3822

    这题说得是给了一个n*m的棋盘,每天在这个棋盘中放置一个棋子,不能放在之前已经摆放过得地方,求最后使得每行每列都有至少一个棋子的期望天数是多少,这样我们考虑怎么放,放哪里,显然数据大而且不知道状态怎么 ...

  2. python tesseract-ocr 安装包下载地址

    https://github.com/UB-Mannheim/tesseract/wiki 如图:可以选合适的版本进行下载

  3. linux 常用命令总结(二)

    1. linux下以指定的编码打开文件:LANG=zh_CN vi fileName 2. 查看系统内存使用,可以使用free -m 或 top 3. 使用env查看所有环境变量 4. df –h 查 ...

  4. C#——文件上传(一般处理程序ashx)

    Framework版本:.Net Framework 4 1.FileInfo实体 using System; using System.Collections.Generic; using Syst ...

  5. 实验五分析system_call中断处理过程

    一.实验要求: 1.使用gdb跟踪分析一个系统调用内核函数 2.根据本周所学知识分析系统调用的过程,从system_call开始到iret结束之间的整个过程,并画出简要准确的流程图 二.实验步骤: 1 ...

  6. target='_blank' 安全漏洞

    有关 target="_blank" 的安全缺陷 可能大家在写网页的时候经常给超链接加个属性 target="_blank",意思就是在浏览器新的窗口打开此超链 ...

  7. git如何自动打补丁

    答:git am --reject jello.patch  (如果打补丁失败,会自动生成rej文件)

  8. linux下强制退出指定用户开启的伪终端

    一.环境 发行版:Ubuntu 18.04.1 LTS 代号:bionic 内核版本:4.15.0-30-generic 二.背景 每次通过ssh登陆服务器,但是超时后自动断开了与服务器的连接,因此在 ...

  9. linux 查看数据库和表

    mysql -h localhost -u 用戶名 -p密碼                //連接數據庫use desk_show;                                 ...

  10. hdu KiKi's K-Number 主席树

    KiKi's K-Number Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...