窗外的知了叽叽喳喳叫个不停,屋里温度应该有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. 联想E431 安装ubuntu16.04

    http://jingyan.baidu.com/article/3c48dd348bc005e10be358eb.html 按照这个教程安装成功!!

  2. 网络基础协议part 1

    1.计算机与计算机之间如何进行联系? 两个独立的计算机是无法进行交流的,如同人一样,如果没有语言的存在就不能正常的交流.而在计算机领域,互联网协议就如同一门计算机与计算机交流的语言.但是为了全世界人们 ...

  3. 计算机基础part1

    一:计算机的基本组成 1.计算机由输入单元.控制单元.算法逻辑单元.输出单元.存储单元,五大单元组成 二:概念篇 CPU:中央处理器,其内含有指令集(取码-解码-执行的过程) CPU同一时刻只能干一件 ...

  4. FIFO的使用总结

    使用FIFO积累 FIFO是在FPGA设计中使用的非常频繁,也是影响FPGA设计代码稳定性以及效率等得关键因素.我总结一下我在使用FIFO过程中的一些心得,与大家分享.         我本人是做有线 ...

  5. [ZJOI2008]泡泡堂BNB

    这个题...是一道神奇的贪心题... 根据田忌赛马的原理... 先假使两队都符合田忌和齐王的配置... 我们可以发现如果我们用当前最弱的...去和对方当前最强的打... 然后一直按照这个方案...当我 ...

  6. 实现简单的shell sed替换功能

    通过脚本传参数可以实现替换 # -*-coding:utf-8-*- # Author:sunhao import sys f = open('yesterday','r',encoding='utf ...

  7. Alpha冲刺2

    前言 队名:拖鞋旅游队 组长博客:https://www.cnblogs.com/Sulumer/p/9960487.html 作业博客:https://edu.cnblogs.com/campus/ ...

  8. 20165214 预备作业3 Linux安装及学习

    一.VirtualBox和Ubuntu的安装 点进VirtualBox的官网后,不知道为什么,我只看到了5.2.6版本...又看到同学反映说5.2.7版本会出现问题,我想可能是工作人员正在补5.2.7 ...

  9. mysql 数据库关于my.int 的相关问题

    最好在建库的时候直接建好 create database db1 charset utf8; my.int  在mysql的目录里 名曰配置文件    里面主要是内容就是 1 一般用到的就是编码不统一 ...

  10. [AOP] 之让人一脸蒙哔的面向切面编程

    最近接触到了面向切面编程,看来很多的文档,算是有一点点了解了,趁自己还有点印象,先把它们给写出来 什么是AOP AOP(Aspect-Oriented Programming), 即 面向切面编程. ...