窗外的知了叽叽喳喳叫个不停,屋里温度应该有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. javascript 字符串函数

    字符串的截取 str.substring(0,index) 字符串转换为日期 <script> var s = "2017-04-10"; var d = s.repl ...

  2. 【2】IOS APP打包发布

    目的: 本文的目的是对IOS APP打包发布做了对应的介绍,大家可根据文档步骤进行mac环境部署: 申请苹果开发者账号 此处略 创建申请证书 这样做的目的就是为你的电脑安装发布许可证,只有这样你的电脑 ...

  3. bzoj4310

    题解: 后缀数组求出本质不同的串 然后二分答案 贪心判断是否可行 代码: #include<bits/stdc++.h> ; using namespace std; typedef lo ...

  4. Java操作FTP工具类(实例详解)

    这里使用Apache的FTP jar 包 没有使用Java自带的FTPjar包  工具类 package com.zit.ftp; import java.io.File; import java.i ...

  5. :工厂模式2:抽象工厂模式--Pizza

    #ifndef __INGREDIENT_H__ #define __INGREDIENT_H__ #include <iostream> using namespace std; cla ...

  6. 2.18 C++类与static关键字

    参考:http://www.weixueyuan.net/view/6349.html 总结: 类中的成员变量或成员函数一旦与static关键字相结合,则该成员变量或成员函数就是属于类的,而不是再是属 ...

  7. htmlayout 最简单的实践,用于理解实现原理。

    / testHtmlayout.cpp : 定义应用程序的入口点. // #include "stdafx.h" #include "testHtmlayout.h&qu ...

  8. shiro学习(二)身份验证

    身份验证,即在应用中谁能证明他就是他本人.一般提供如他们的身份ID一些标识信息来表明他就是他本人,如提供身份证,用户名/密码来证明. 在shiro中,用户需要提供principals (身份)和cre ...

  9. 在Ubuntu上搭建IntelliJ IDEA license server服务器

    1.下载激活文件 2.ubuntu需要使用 IntelliJIDEALicenseServer_linux_amd64 ,把该文件传到服务器的某个目录,我是放在了/jideal 下 3.进入上面的目录 ...

  10. SQL注入之Sqli-labs系列第二十三关(基于过滤的GET注入)

    开始挑战第二十三关(Error Based- no comments) 先尝试下单引号进行报错 再来利用and来测试下,加入注释符#,编码成%23同样的报错 再来试试--+,同样的效果 同样的,先看看 ...