《DSP using MATLAB》Problem 5.24-5.25-5.26
代码:
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的更多相关文章
- 《DSP using MATLAB》Problem 7.24
又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 6.24
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 4.24
Y(z)部分分式展开, 零状态响应部分分式展开, 零输入状态部分分式展开,
- 《DSP using MATLAB》Problem 6.15
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 6.8
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 4.15
只会做前两个, 代码: %% ---------------------------------------------------------------------------- %% Outpu ...
- 《DSP using MATLAB》Problem 2.16
先由脉冲响应序列h(n)得到差分方程系数,过程如下: 代码: %% ------------------------------------------------------------------ ...
- 《DSP using MATLAB》 Problem 2.3
本题主要是显示周期序列的. 1.代码: %% ------------------------------------------------------------------------ %% O ...
- 《DSP using MATLAB》Problem 7.29
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
随机推荐
- lubuntu16.04 安装过程以及ssd测试模型的环境配置
1.系统启动盘(ultraISO)制作启动盘, 1/5 文件->打开,打开我们的iso镜像 2/5 选择我们的u盘, 3/5 点击启动->写入硬盘映像 4/5 写入方式选择raw,格式化然 ...
- Saiku的基本使用介绍(三)
Saiku的基本使用介绍(这里都是使用Admin用户登录系统) 1.启动安装好的Saiku ( ./start-saiku.sh ) ,浏览器使用访问系统 http://localhost:8080 ...
- RabbitMQ direct类型的Exchange
就目前来说,Exchange是与消息发送端有关的,因为它可以指定将消息发送到哪个或哪些队列中. 本篇文章介绍的direct类型就是指定将消息定向发送到哪个队列中. direct,顾名思义,就是直接的意 ...
- Python自动化必备发送邮件报告脚本详解
#!/usr/bin/python3# -*- coding:UTF-8 -*-import smtplib#smtplib库主要用来连接第三方smtp库,用来发邮件from email.mime.t ...
- Spring MVC中注解: @ModelAttribute 与@RequestParam区别
相关链接 : https://blog.csdn.net/huang343/article/details/77491096
- OpenStack平台虚拟机实例在线迁移失败问题
一.在线迁移时提示如下的报错 二.原因分析 通过kolla-ansible部署queens版本时,因为OEM的机器设备的UUID记录的一致,导致迁移时识别的是自身机器的UUID,导致迁移失败 三.问题 ...
- 201621123001 《Java程序设计》第11周学习总结
1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多线程相关内容. 一个进程可以同时运行多个不同线程,不同的线程执行不同的任务 Java线程是通过java.lang包中定义的Thre ...
- C#窗体换肤
Form1.cs using System;using System.Collections.Generic;using System.ComponentModel;using System.Data ...
- 如何HACK无线家用警报器?
30年前,报警器都是硬连线的,具有分立元件,并由钥匙开关操作.20年前,他们已经演变为使用微控制器,LCD和键盘,但仍然是硬连线.10年前,无线报警器开始变得普及,并增加了许多之前没有的功能. 而如今 ...
- 爬虫系列1:python简易爬虫分析
决定写一个小的爬虫系列,本文是第一篇,讲爬虫的基本原理和简易示例. 1.单个网页的简易爬虫 以下爬虫的主要功能是爬取百度贴吧中某一页面的所有图片.代码由主要有两个函数:其中getHtml()通过页面u ...