《DSP using MATLAB》示例 Example 10.1
坚持到第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的更多相关文章
- 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; % ...
- 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 ...
- 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 ...
- DSP using MATLAB 示例 Example3.19
代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signa ...
- DSP using MATLAB示例Example3.18
代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Continuous-time Fou ...
- 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 ...
- 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 , ...
- DSP using MATLAB 示例 Example3.11
用到的性质 上代码: n = -5:10; x = rand(1,length(n)); k = -100:100; w = (pi/100)*k; % freqency between -pi an ...
- 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 = ...
- 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; % [ ...
随机推荐
- laravel 多图上传
前台 name="photo[]" 后台获取 $request->file('photo');//获取多个图片循环
- cookie的存取删
存: document.cookie = "name=Kevin;expires="+new Date().getDate()+7; //有效期7天 取: function Get ...
- 常用php操作redis命令整理(二)哈希类型
HSET将哈希表key中的域field的值设为value;如果field是哈希表中的一个新建域,并且值设置成功,返回1;如果哈希表中域field已经存在且旧值已被新值覆盖,返回0. <?php ...
- FastDFS+Nginx分布式文件系统部署安装
安装: ##安装tracker.storage参考:http://www.cnblogs.com/zclzhao/p/5025229.html nginx代理设置参考:http://www.cnblo ...
- linux下如何退出tmux和重新进入tmux
1.退出(detach)当前tmux ctrl+d 2.重新进入tmux tmux attach -t <target-session> 如:当前有很多session,那么选择哪一个呢? ...
- [fastjson] - fastjson中 JSONObject 和 JSONArray
/** * 对jsonObject对象进行key的获取 * @param jsonObject */ public ArrayList<String> jsonKeyRecursion(J ...
- git submodule临时分支;以及git reset使用
submodule 已经建立好了一个gitlab submodule形式的repo: 在repo A下面有一个submodule B, A --> B. clone -b branch [rep ...
- Mongo配置基础
数据库也是一种服务,数据库的本质也是一个文件,所以说我们把文件存入text和存入数据库的本质是一样的,只是数据库的格式化的删除和添加. 分为四部分, mongo的启动详解 导入导出,运行时备份 Fsy ...
- C#正则_取出标签内的内容(非贪婪)
using System.Text.RegularExpressions; /// <summary> /// 执行正则提取出值 /// </summar ...
- python爬虫脚本下载YouTube视频
python爬虫脚本下载YouTube视频 爬虫 python YouTube视频 工作环境: python 2.7.13 pip lxml, 安装 pip install lxml,主要用xpath ...