窗外的知了叽叽喳喳叫个不停,屋里温度应该有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的更多相关文章

  1. 《DSP using MATLAB》Problem 6.20

    先放子函数: function [C, B, A, rM] = dir2fs_r(h, r); % DIRECT-form to Frequency Sampling form conversion ...

  2. 《DSP using MATLAB》Problem 4.20

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  3. 《DSP using MATLAB》Problem 3.20

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  4. 《DSP using MATLAB》Problem 2.20

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  5. 《DSP using MATLAB》Problem 7.24

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

  6. 《DSP using MATLAB》Problem 7.23

    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...

  7. 《DSP using MATLAB》Problem 6.15

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

  8. 《DSP using MATLAB》Problem 6.12

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

  9. 《DSP using MATLAB》Problem 6.10

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

随机推荐

  1. java串口编程

    报错:no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDrive java.lang.Unsatisfie ...

  2. [POJ2985]The k-th Largest Group

    Problem 刚开始,每个数一个块. 有两个操作:0 x y 合并x,y所在的块 1 x 查询第x大的块 Solution 用并查集合并时,把原来的大小删去,加上两个块的大小和. Notice 非旋 ...

  3. Struts2的基础知识

    Struts2属于MVC框架 Struts2的优点: 1.侵入性低 2.提供了拦截器,可以利用拦截器进行AOP编程 3.提供了类型转换器 4.支持多种表示层技术:jsp,freeMarker,Vele ...

  4. 【转】MySQL实现Oracle里的 rank()over(ORDER BY) 功能

    Oracle rank()和dense_rank()的区别是: –rank()是跳跃排序,有两个第二名时接下来就是第四名 –dense_rank()l是连续排序,有两个第二名时仍然跟着第三名 sele ...

  5. ubuntu14.04 解析不了域名—ubuntu的DNS配置

    问题描述: 电脑系统为ubuntu14.04,连上无线后,火狐浏览器打开www.baidu.com,提示找不到服务器,以及终端ping www.baidu.com,提示unkown host,但是浏览 ...

  6. confirm消息对话框

    function rec(){ var mymessage= confirm("你是女孩?") ; if(mymessage==true) { document.write(&qu ...

  7. Vue 项目架构设计与工程化实践

    来源 文中会讲述我从0~1搭建一个前后端分离的vue项目详细过程 Feature: 一套很实用的架构设计 通过 cli 工具生成新项目 通过 cli 工具初始化配置文件 编译源码与自动上传CDN Mo ...

  8. centos /data目录扩容

    /data盘被日志撑死了,必须扩容 有一块现成的100G的/dev/sdb盘,但是mount到了/data/test目录下,而且还有应用程序在上面进行读写操作 1.先查看哪些应用程序 在占用磁盘 #f ...

  9. js基础 三种弹出框 数据类型

    总结:js三个组成部分ES:语法DOM:对象模型 => 通过js代码与页面文档(出现在body中的所有可视化标签)进行交互BOM:对象模型 => 通过js代码与浏览器自带功能进行交互 引入 ...

  10. 基于区域的OSPF的MD5认证

    实验要求:掌握OSPF基于区域的MD5认证 拓扑如下: 配置如下: R1enable configure terminal interface s0/0/0ip address 192.168.1.1 ...