《DSP using MATLAB》Problem5.33

代码:
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.33 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % -------------------------------------------------------------
% x3(n) --- N-point circular convolution of x1(n) an x2(n)
% x4(n) --- Linear convolution
% e(n) --- error sequence
% ------------------------------------------------------------- N = 8;
n1 = [0:3];
x1 = [2, 1, 1, 2];
N1 = length(x1); n2 = [0:3];
x2 = [1, -1, -1, 1];
N2 = length(x2); % --------------------------------------------
% 1st way ---- time domain
% --------------------------------------------
N
y1 = circonvt(x1, x2, N)
ny1 = [0:N-1]; % --------------------------------------------
% 2nd way ---- DFT method
% -------------------------------------------- y2 = circonvf(x1, x2, N);
ny2 = [0:N-1]; % --------------------------------------------
% 3rd way --- circulant matrix
% -------------------------------------------- y3 = circonvt_v3(x1, x2, N);
ny3 = [0:N-1]; % ---------------------------------------
% Linear convolution
% --------------------------------------- [y4, ny4] = conv_m(x1, n1, x2, n2); %e1 = y1 - y4(1:N); figure('NumberTitle', 'off', 'Name', 'P5.33 x1(n) and x2(n) N=4')
set(gcf,'Color','white');
subplot(2,1,1); stem(n1, x1);
xlabel('n'); ylabel('x1(n)');
title('x1(n)'); grid on;
subplot(2,1,2); stem(n2, x2);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('n'); ylabel('x2(n)');
title('x2(n)'); grid on; figure('NumberTitle', 'off', 'Name', 'P5.33 Cir-Conv(N=8) and Linear-Conv')
set(gcf,'Color','white');
subplot(2,2,1); stem(ny1, y1);
xlabel('n'); ylabel('y1(n)');
title('Cir-Conv (Time domain), y1(n)'); grid on;
subplot(2,2,2); stem(ny2, y2);
%axis([0, N, 0, 1]);
xlabel('n'); ylabel('y2(n)');
title('Cir-Conv (DFT method), y2(n)'); grid on;
subplot(2,2,3); stem(ny3, y3);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('n'); ylabel('y3(n)');
title('Cir-Conv (circulant matrix), y3(n)'); grid on;
subplot(2,2,4); stem(ny4, y4);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('n'); ylabel('y4(n)');
title('Linear-Conv, y4(n)'); grid on;
运行结果:


y1--圆周卷积,N=4;y4---线性卷积,长度为7


由下图可知,当N=7时,序列的圆周卷积和线性卷积结果相同。



结论:两序列x1长N1,x2长N2,当N至少取N1+N2-1做圆周卷积,结果和线性卷积相同。
《DSP using MATLAB》Problem5.33的更多相关文章
- 《DSP using MATLAB》Problem5.23
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% O ...
- 《DSP using MATLAB》Problem5.16
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》示例Example7.25
今天清明放假的第二天,早晨出去吃饭时天气有些阴,十点多开始“清明时节雨纷纷”了. 母亲远在他乡看孙子,挺劳累的.父亲照顾生病的爷爷…… 我打算今天把<DSP using MATLAB>第7 ...
- 《DSP using MATLAB》Problem 8.33
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》Problem 7.33
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》示例 Example 9.14
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》 示例 Example 9.12
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》示例Example 9.9
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》示例 Example 9.6
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
随机推荐
- BootStrap字体图标不显示、下拉菜单不显示
在W3CSchool学习BootStrap教程时遇到的问题…… 1.字体图标不能显示 上面是正常显示的样子,不能正常显示,因为缺少下面的字体图标样式文件 (1)在下载的Bootstrap包中将font ...
- vue-router-8-路由组件传参
在组件中使用$route会使之与其对应路由形成高度耦合,使用props解耦 const User = { props: ['id'], template: '<div>User{{ id ...
- memset详解 设置无穷大INF
memest原型 (please type "man memset" in your shell) void *memset(void *s, int c, size_t n); ...
- 自旋锁(Spin Lock)
转载请您注明出处: http://www.cnblogs.com/lsh123/p/7400625.html 0x01 自旋锁简介 自旋锁也是一种同步机制,它能保证某个资源只能被一个线程所拥有, ...
- 初始化集合的花样new HashMap<String, String>{ {put("str1":"abc");} }(转)
Map集合的普通初始化方法: Map<String, String> map = new HashMap<String, String>(); map.put("Na ...
- <Spark Streaming><本地调试>
写在前面 因为本地电脑没装flume,nginx各种.所以之前写Streaming程序的时候,都是打包了放到集群上跑.就算我在程序代码里不停地logger,调试起来也hin不方便. 于是本地写了两个程 ...
- Strict Standards: Declaration of UserModel::toJSON() should be compatible with that of BaseModel::toJSON()
使用php报了这个错误: 错误的意思是: 严格标准: usermodel中的 toJSON() 方法 应该 同 BaseModel中的toJson() 方法是兼容的. php要求 子类的方法如果同父 ...
- mail命令入门及进阶
mail是linux shell中的邮件工具,与crontab配合使用,可以实现定期发送邮件.本文主要介绍mail工具使用方法及注意事项. 1.mail命令一般用法: mail –s "邮件 ...
- 在Intellij IDEA中修改模板中user变量名称
在Intellij IDEA中的注释模板中的${user}名称是根据当前操作系统的登录名来取的,有时候登录名称和我们实际的user名称并不相同. 修改方法如下: 方法一:可以在settings的fil ...
- Python 黏包及黏包解决方案
粘包现象 说粘包之前,我们先说两个内容,1.缓冲区.2.windows下cmd窗口调用系统指令 1 缓冲区(下面粘包现象的图里面还有关于缓冲区的解释) 每个 socket 被创建后,都会分配两个缓冲区 ...