坚持到第10章了,继续努力!

代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Exameple 10.1 \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; n = [1:N];
xn = (1/3)*(sin(n/11) + sin(n/31) + cos(n/67)); clear n; % 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.1a');
set(gcf,'Color','white');
TF = 10;
title('Normalized error e1 and e2');
subplot(2, 1, 1);
bar(Q, H1); axis([-0.5, 0.5, -0.001, 4/128]); grid on; 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 = 6
%% ---------------------------------------------------------------------
% Example parameters
B = 6; N = 500000; n = [1:N];
xn = (1/3)*(sin(n/11) + sin(n/31) + cos(n/67)); clear n; % 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 Hf2 = figure('units', 'inches', 'position', [1, 1, 8, 6], ...
'paperunits', 'inches', 'paperposition', [0, 0, 6, 4], ...
'NumberTitle', 'off', 'Name', 'Exameple 10.1b');
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'); 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 = %.7f', estat(2))) ; subplot(2, 1, 2);
bar(Q, H2); axis([-0.5, 0.5, -0.001, 4/128]); grid on;
title('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 = %.7f', estat(4))) ;

  运行结果:

B=2的结果如第1张图所示,很明显,即使误差看起来均匀分布,但误差采样序列不是独立的。对应B=6的
结果如第2张图所示,当B≥6时,结果满足误差模型假设条件。

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

  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. Linux系统——Nginx基础

    Nginx是一个开源的,支持高性能.高并发(特别是静态资源)的www服务和代理服务软件,还具有反向代理复杂均衡功能和缓存服务功能,与lvs负载均衡及Haproxy等专业代理软件相比,nginx部署更简 ...

  2. in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)

    最近在用ruby的一些库的时候,总是出现这个错误. 在使用net/imap库的时候,或者net/http库(主要是用到了https,https是用了ssl) 的时候,具体如下: 错误提示:E:/Rub ...

  3. JAVA构建高并发商城秒杀系统——架构分析

    面试场景 我们打算组织一个并发一万人的秒杀活动,1元秒杀100个二手元牙刷,你给我说说解决方案. 秒杀/抢购业务场景 商品秒杀.商品抢购.群红包.抢优惠劵.抽奖....... 秒杀/抢购业务特点 秒杀 ...

  4. 爬取乌云上所有人民币和乌云符号的漏洞(python脚本)

    import httplib from HTMLParser import HTMLParser import urlparse import urllib from bs4 import Beaut ...

  5. EF Code First学习笔记:数据库创建(转)

    控制数据库的位置 默认情况下,数据库是创建在localhost\SQLEXPRESS服务器上,并且默认的数据库名为命名空间+context类名,例如我们前面的BreakAway.BreakAwayCo ...

  6. Qml应用程序的性能考虑与建议

    本文翻译自Qt官网文档: http://doc.qt.io/qt-5/qtquick-performance.html QtQml应用程序的性能考虑与建议 1.时间考虑 作为一名程序开发者,应该努力使 ...

  7. Knockout 监控数组对象属性

    代码: function Product(ProductID,ProductName,ProductNum,Result,Price) { this.ProductID = ko.observable ...

  8. codeforces 97 div2 C.Replacement 水题

    C. Replacement time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  9. PostgreSql 其它客户端连接

    在 PATH_TO_YOUR_PostGreSQL/data/pg_hba.conf 加上红色那行,重启postgre的service就能让其它人连你的数据库了. host all all 127.0 ...

  10. Postman模拟高并发执行

    一次,执行1000次. 看看服务器能否承受住. 查看每一次的执行情况,查看总的执行情况.成功情况,失败情况.