《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 ...
随机推荐
- laravel创建新的提交数据
public function store() { $this->validate(request(),[ 'title'=>'required|string|max:100|min:10 ...
- learning at command AT+CIMI
AT command AT+CIMI [Purpose] Learning how to get the International Mobile Subscriber Identity ...
- TTL集成门电路工作原理和电压传输特性
集成电路(Integrated Circuit 简称IC):即把电路中半导体器件,电阻,电容以及连线等制作在一块半导体基片上构成一个完整的电路,并封装到一个管壳内 集成电路的有点:体积小,重量轻,可靠 ...
- session和cokkie的区别与作用
session在计算机中,尤其是在网络应用中,称为“会话机制”,Session对象存储特定用户会话所需的属性及配置信息,这样,当用户在应用程序的web页之间跳转时,存储在session对象中的变量将不 ...
- JavaScript示例
<!DOCTYPE html> <html> <head> <title>单击按钮事件示例</title> <script langu ...
- IDEA中自动生成serialVersionUID
File >> Setting >> Inspections >> serializable 勾选上后,光标放在实现Serializable接口的类名上 ...
- spoon 更新数据
一个小需求,被要求使用spoon 来同步数据 主要流程为: 1.查询A库未同步数据 id 2.根据步骤1查到的id,作为条件更新B库数据 3.更新B库数据成功则更改库A中的数据状态为已同步. 4.添加 ...
- jetty域证书更新
服务器:centos6.6 1.从正确的.pfx文件中导出.pem认证文件 #openssl pkcs12 -in example.pfx -nodes -out server.pem pfx文件可以 ...
- 解决Invalid bound statement (not found): com.cqupt.ssm.dao.UserDao.queryMenu问题
今天写项目时多加了个查询菜品的方法报错: Invalid bound statement (not found): com.cqupt.ssm.dao.UserDao.queryMenu 大概意思是找 ...
- HIVE点滴:group by和distinct语句的执行顺序
同一条语句之中,如果同时有group by和distinct语句,是先group by后distinct,还是先distinct后group by呢? 先说结论:先group by后distinct. ...