《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 ...
随机推荐
- linux command mktemp
Linux command mktemp [Purpose] Learning linux command mktemp to create a temporary file or di ...
- python 学习笔记 字符串和编码
字符编码:因为计算机只能处理数字,如果要处理文本,就必须先把文本转换为数字才能处理,最早的计算机在设计时采用8个比特(bit)作为一个字节 (byte),所以,一个字节能表示的最大的整数是255(二进 ...
- 【原创】imread () 函数 读入图片的例子
Reference Links Opencv+ qt5.1 完美配置 - 脚踏实地 - 博客频道 - CSDN.NET http://blog.csdn.net/xiaojidan2011/arti ...
- jenkins部署web项目到tomcat(五)
(1)maven构建web项目 pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=&q ...
- 前端基础之CSS属性
一.背景属性 <style> p { /*背景颜色*/ background-color: red; /*字体颜色*/ color: blue; /*宽度和高度*/ width: 600p ...
- 侧滑返回导航栏以及TabBar隐藏和显示带来的坑
用系统的UINavigationBar时,返回手势重若碰到前一个页面有bar,后一个页面没bar,或者反过来时动画非常难看 如下图:因为首页隐藏了导航栏,在侧滑的时候导航栏竟然提前消失了,这是因为在侧 ...
- 下载python中package的简便方法
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple xxx
- [SCOI2005]栅栏
这个题...只能说比较水... 排序后,算一个前缀和,二分dfs查找答案...加上两个剪枝就过了...QVQ 我只能刷这种水题...我太菜了...QVQ #include<iostream> ...
- CountDownLatch在多线程程序中的应用
一.CountDownLatch介绍 CountDownLatch是JDK1.5之后引入的,存在于java.util.concurrent包下,能够使一个线程等待其他线程完成动作后再执行.构造方法: ...
- hdu5335(bfs,贪心)
In an n∗mn∗m maze, the right-bottom corner is the exit (position (n,m)(n,m) is the exit). In every p ...