《DSP using MATLAB》Problem 5.20
窗外的知了叽叽喳喳叫个不停,屋里温度应该有30°,伏天的日子难过啊!
频率域的方法来计算圆周移位
代码:
子函数的
function y = cirshftf(x, m, N)
%% -----------------------------------------------------------------------
% Circular shift of m samples wrt size N in sequence x: (freq domain)
% ---------------------------------------------------------------------
% y = cirshftf(x, m, N)
% y : output sequence containing the circular shift
% x : input sequence of length <= N
% m : sample shift
% N : size of circular buffer
% Method : y(n) = idft( dft(x(n)) * WN ^ (mk)) % if m is a scalar then y is a sequence (row vector)
% if m is a vector then y is a matrix, each row is a circular shift
% in x corresponding to entries in vector m
% M and x should not be matrices if length(x)>N
error('N must >= length(x)' )
end x = [x zeros(1, N-length(x))];
k = [0:1:N-1]; WN = exp(-j*2*pi/N);
mk = m*k; y = real(idft( dft(x, N) .* ( WN .^ (mk) ), N ));
主函数的
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.20 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % ---------------------------------------------------------------------------------
% circular shift
% method 1 : cirshftt function, time domain
% method 2 : cirshftf function, freq domain
%
% ---------------------------------------------------------------------------------
n = [0:10];
x = [5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4]; % N=11 sequence m1 = -5; N1 = 12;
n1 = [0:N1-1]; m2 = 8; N2 = 15;
n2 = [0:N2-1]; % -----------------------------------------------------
% 1st way to get circular shift---time domain
% -----------------------------------------------------
y1_1 = cirshftt(x, m1, N1);
y2_1 = cirshftt(x, m2, N2); % --------------------------------------------------------
% 2rd way to get circular shift --- freq domain
% --------------------------------------------------------
y1_2 = cirshftf(x, m1, N1);
y2_2 = cirshftf(x, m2, N2); figure('NumberTitle', 'off', 'Name', 'P5.20.a x(n) and its cir shift')
set(gcf,'Color','white');
subplot(3,1,1); stem(n, x);
xlabel('n'); ylabel('x(n)');
title('x(n), N=11'); grid on;
subplot(3,1,2); stem(n1, y1_1);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('n'); ylabel('y(n)');
title('TIME domain circular shift x(n), m=-5, N=12'); grid on;
subplot(3,1,3); stem(n1, y1_2);
xlabel('n'); ylabel('y(n)');
title('FREQ domain circular shift x(n), m=-5, N=12'); grid on;
axis([0, N1, 0, 6]); figure('NumberTitle', 'off', 'Name', 'P5.20.b x(n) and its cir shift')
set(gcf,'Color','white');
subplot(3,1,1); stem(n, x);
xlabel('n'); ylabel('x(n)');
title('x(n), N=11'); grid on;
subplot(3,1,2); stem(n2, y2_1);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('n'); ylabel('y(n)');
title('TIME domain circular shift x(n), m=8, N=15'); grid on;
subplot(3,1,3); stem(n2, y2_2);
xlabel('n'); ylabel('y(n)');
title('FREQ domain circular shift x(n), m=8, N=15'); grid on;
axis([0, N2, 0, 6]);
运行结果:
《DSP using MATLAB》Problem 5.20的更多相关文章
- 《DSP using MATLAB》Problem 6.20
先放子函数: function [C, B, A, rM] = dir2fs_r(h, r); % DIRECT-form to Frequency Sampling form conversion ...
- 《DSP using MATLAB》Problem 4.20
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》Problem 3.20
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》Problem 2.20
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》Problem 7.24
又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.23
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...
- 《DSP using MATLAB》Problem 6.15
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 6.12
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 6.10
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
随机推荐
- day29-python阶段性复习三
七.python打开文件方式 open r: 读的方式 w:已写的方式打开 a:以追加的方式 r+ 读写模式 w+ 读写 a+ 读写 rb:二进制读模式打开 wb:以二进制写模式打开 ab 二进制追加 ...
- Mysql数据库操作语句总结
简单复习下: 增insert into -- 删 delete from -- 改 update table名字 set -- 查 select * from -- 一.SQL定义 SQL(Str ...
- mysql存储过程造数
性能测试时,数据库表通常需要很多数据,此时我们可以用存储过程来造数,以下代码mysql.Oracle都可以用 首先,先查看数据库表的设计,可以看到每张表有多少字段,分别都是什么类型,哪个字段是自动增长 ...
- Spring Boot学习笔记----POI(Excel导入导出)
业务:动态生成模板导出Excel,用户修改完再导入Excel. Spring boot + bootstrap + poi 1.添加Dependence <dependency> < ...
- DevExpress WinForms使用教程:WinForms Sunburst控件
[DevExpress WinForms v18.2下载] DevExpress WinForms v18.2中包含了一个新的WinForms组件 - WinForms Sunburst,它旨在帮助开 ...
- java.lang.ClassNotFoundException: com.mysql.jdbc.Driver 解决方法
1.导入mysql-connector-java-5.1.26-bin.jar包,我试着把maven中自动下载下来的mysql-connector-java-5.1.26.jar包导入,还是没能解决问 ...
- ResNet 简介
resnet 又叫深度残差网络 图像识别准确率很高,主要作者是国人哦 深度网络的退化问题 深度网络难以训练,梯度消失,梯度爆炸,老生常谈,不多说 resnet 解决了这个问题,并且将网络深度扩展到了最 ...
- java中coroutine使用
链接1:http://jm.taobao.org/2010/09/17/326/ 链接2:https://www.jianshu.com/p/0f1a6943eab5
- Vue数组操作不刷新视图问题的解决
最近使用Vue2.0开发项目,有一个列表使用v-for绑定到数组,按照Vue的推荐方案,使用push.splice.this.$set三个变异方法操作数组.发现在添加页面,三个方法都能及时刷新视图:但 ...
- 17 多校1 Add More Zero 水题
Problem Description There is a youngster known for amateur propositions concerning several mathemati ...