代码:

function y = circonvt(x1,x2,N)
%% N-point Circular convolution between x1 and x2: (time domain)
%% ------------------------------------------------------------------
%% [y] = circonvt(x1,x2,N)
%% y = output sequence containning the circular convolution
%% x1 = input sequence of length N1 <= N
%% x2 = input sequence of length N2 <= N
%%
%% N = size of circular buffer
%% Method: y(n) = sum( x1(m)*x2((n-m) mod N) )
%% Check for length of x1 if length(x1) > N
error('N must be >= the length of x1 !')
end
%% Check for length of x2 if length(x2) > N
error('N must be >= the length of x2 !')
end x1 = [x1 zeros(1,N-length(x1))];
x2 = [x2 zeros(1,N-length(x2))]; m = [0:1:N-1]; x2 = x2(mod_1(-m, N)+1); H = zeros(N,N);
for n = 1:1:N
H(n,:) = cirshftt(x2,n-1,N);
end
y = x1*conj(H'); % x1---row vector
% H
% y = H*x1'; % x1---column vector

  主程序:

%% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.24 \n\n'); banner();
%% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % -------------------------------------------------------------------
%
% -------------------------------------------------------------------
N = 4;
n1 = [0:3];
x1 = [1, 2, 2]; x2 = [1, 2, 3, 4]; y1 = circonvt(x1, x2, N)

  运行结果:

代码:

function [C] = circulnt(x, N)
%% Circulant Matrix from an N-point sequence
%% ------------------------------------------------------------------
%% [C] = circulnt(x, N)
%% C = Circulant Matrix of size NxN
%% x = sequence of length <= N
%%
%% N = size of circulant matrix
if length(x) > N
error('N must be >= the length of x !')
end x = [x zeros(1, N-length(x))]; for i = 1 : N
c(i) = x(i);
end m = [0:1:N-1]; x_fold = x(mod_1(-m, N)+1);
r = x_fold; C = toeplitz(c,r);

  

function y = circonvt_v3(x1,x2,N)
%% N-point Circular convolution between x1 and x2: (time domain)
%% ------------------------------------------------------------------
%% [y] = circonvt(x1,x2,N)
%% y = output sequence containning the circular convolution
%% x1 = input sequence of length N1 <= N
%% x2 = input sequence of length N2 <= N
%%
%% N = size of circular buffer
%% Method: y(n) = sum( x1(m)*x2((n-m) mod N) )
%% Check for length of x1 if length(x1) > N
error('N must be >= the length of x1 !')
end
%% Check for length of x2
if length(x2) > N
error('N must be >= the length of x2 !')
end x1 = [x1 zeros(1,N-length(x1))];
x2 = [x2 zeros(1,N-length(x2))]; C = circulnt(x2, N); % m = [0:1:N-1]; x2 = x2(mod_1(-m, N)+1); H = zeros(N,N);
% for n = 1:1:N
% H(n,:) = cirshftt(x2,n-1,N);
% end
% y = x1*conj(H'); % x1---row vector y = C*x1'; % x1---column vector

  

%% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.25 \n\n'); banner();
%% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % -------------------------------------------------------------------
%
% -------------------------------------------------------------------
N = 4;
n1 = [0:3];
x1 = [1, 2, 2]; x2 = [1, 2, 3, 4]; %C = circulnt(x2, 4); y1 = circonvt_v3(x1, x2, N)

  运行结果:

代码:

function x3 = circonvf(x1, x2, N)
%% N-point Circular convolution between x1 and x2: (frequency domain)
%% ------------------------------------------------------------------
%% [x3] = circonvf(x1,x2,N)
%% x3 = output sequence containning the circular convolution
%% x1 = input sequence of length N1 <= N
%% x2 = input sequence of length N2 <= N
%%
%% N = size of circular buffer
%% Method: x3(n) = IDFT[X1(k)X2(k)] %% Check for length of x1
if length(x1) > N
error('N must be >= the length of x1 !')
end
%% Check for length of x2
if length(x2) > N
error('N must be >= the length of x2 !')
end x1 = [x1 zeros(1,N-length(x1))];
x2 = [x2 zeros(1,N-length(x2))]; X1k_DFT = dft(x1, N);
X2k_DFT = dft(x2, N); x3 = real(idft( X1k_DFT.* X2k_DFT, N));

  

%% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.26 \n\n'); banner();
%% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % -------------------------------------------------------------------
%
% -------------------------------------------------------------------
N = 4;
n1 = [0:3];
x1 = [4,3,2,1];
%x1 = [1,2,2]; n2 = [0:3];
x2 = [1, 2, 3, 4]; %C = circulnt(x2, 4); y1 = circonvf(x1, x2, N)

  运行结果:

《DSP using MATLAB》Problem 5.24-5.25-5.26的更多相关文章

  1. 《DSP using MATLAB》Problem 7.24

    又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...

  2. 《DSP using MATLAB》Problem 6.24

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  3. 《DSP using MATLAB》Problem 4.24

    Y(z)部分分式展开, 零状态响应部分分式展开, 零输入状态部分分式展开,

  4. 《DSP using MATLAB》Problem 6.15

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  5. 《DSP using MATLAB》Problem 6.8

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  6. 《DSP using MATLAB》Problem 4.15

    只会做前两个, 代码: %% ---------------------------------------------------------------------------- %% Outpu ...

  7. 《DSP using MATLAB》Problem 2.16

    先由脉冲响应序列h(n)得到差分方程系数,过程如下: 代码: %% ------------------------------------------------------------------ ...

  8. 《DSP using MATLAB》 Problem 2.3

    本题主要是显示周期序列的. 1.代码: %% ------------------------------------------------------------------------ %% O ...

  9. 《DSP using MATLAB》Problem 7.29

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

随机推荐

  1. Saiku连接mysql数据库(二)

    Saiku连接Mysql数据库展示数据 参考链接:https://www.cnblogs.com/shirui/p/8573491.html 官方文档:https://media.readthedoc ...

  2. jps -- process information unavailable

    在之前停止java进程时,使用了 kill -9,结果进程未正常退出. 之后每次执行 jps 命令时都会打印出 -- process information unavailable 在ls /tmp/ ...

  3. Maven 加载ojdbc14.jar报错,解决方法

    因为oracle的ojdbc.jar是收费的,所以maven的中央仓库中没有这个资源,只能通过配置本地库才能加载到项目中去. 首先下载 ojdbc14  https://pan.baidu.com/s ...

  4. requests(第三方模块) 请求、登录、下载网页

    import requests  #http://docs.python-requests.org/en/latest/api/ 说明文档 ''' requests.request(method,ur ...

  5. 运行java程序的方法-DOS命令和Eclipse方法

    ● 运行java程序的方法(使用DOS命令) 首先进行一个"文件夹选项"的设置: 在D:\Android\java_code目录下新建了一个Hello_World.java文件(不 ...

  6. 强化学习8-时序差分控制离线算法Q-Learning

    Q-Learning和Sarsa一样是基于时序差分的控制算法,那两者有什么区别呢? 这里已经必须引入新的概念 时序差分控制算法的分类:在线和离线 在线控制算法:一直使用一个策略选择动作和更新价值函数, ...

  7. set,pair容器使用方法

    题目链接:http://codeforces.com/gym/100989/problem/D In this cafeteria, the N tables are all ordered in o ...

  8. ClickOnce 和管理员权限

    有些程序需要管理员权限需要运行,同时又想用ClickOnce进行发布,这时候就麻烦了,两者是互斥的. 解决方案是,去掉管理员权限的要求,可以进行发布. 程序启动的时候,加载程序员权限的请求. 代码如下 ...

  9. h5页面嵌入android app时遇到的问题

    1.h5页面 通过 .css("transform") 或 .style.transform 获取 transform属性,并通过 split 方法解析 页面translateY ...

  10. 20165214 实验二 Java面向对象程序设计

    一.实验报告封面 课程:Java程序设计 班级:1652班 姓名:朱文远 学号:20165214 指导教师:娄嘉鹏 实验日期:2018年4月16日 实验时间:13:45 - 15:25 实验序号:二 ...