《DSP using MATLAB》Problem5.16
代码:
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.16 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % -------------------------------------------------------------------------------
% X(k) and Y(k) both 10-point DFTs of x(n) and y(n) respectively
% X(k) = exp(j0.2pi*k) k=[0:9]
% 1 y(n) = x((n-5))10
% ------------------------------------------------------------------------------- k1 = [0:9];
Xk_DFT = exp(j*0.2*pi*k1);
N1 = length(Xk_DFT); % length is 10 magXk_DFT = abs( [ Xk_DFT ] ); % DFT magnitude
angXk_DFT = angle( [Xk_DFT] )/pi; % DFT angle
realXk_DFT = real(Xk_DFT); imagXk_DFT = imag(Xk_DFT); figure('NumberTitle', 'off', 'Name', 'P5.16.1 DFT(k) of x(n)')
set(gcf,'Color','white');
subplot(2,1,1); stem(k1, magXk_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('magnitude(k)');
title('DFT magnitude of x(n), N=10'); grid on;
subplot(2,1,2); stem(k1, angXk_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('angle(k)');
title('DFT angle of x(n), N=10'); grid on; [xn] = idft(Xk_DFT, N1);
n = [0 : N1-1]; % +++++++++++++++++++++++++++++++++++++++++++++++++++++++
% 1st way to get y(n)-----circular shifft
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++
m = 5; % shift
yn1 = cirshftt(xn, m, length(xn)); % +++++++++++++++++++++++++++++++++++++++++++++++++++++++
% 2ed way to get y(n)-----IDFT of Y(k)
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++
k1 = [0:9];
Yk_DFT = exp(-j*0.8*pi*k1);
N1 = length(Yk_DFT); % length is 10 magYk_DFT = abs( [ Yk_DFT ] ); % DFT magnitude
angYk_DFT = angle( [Yk_DFT] )/pi; % DFT angle
realYk_DFT = real(Yk_DFT); imagYk_DFT = imag(Yk_DFT); figure('NumberTitle', 'off', 'Name', 'P5.16.1 DFT(k) of y(n)')
set(gcf,'Color','white');
subplot(2,1,1); stem(k1, magYk_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('magnitude(k)');
title('DFT magnitude of y(n), N=10'); grid on;
subplot(2,1,2); stem(k1, angYk_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('angle(k)');
title('DFT angle of y(n), N=10'); grid on; [yn2] = idft(Yk_DFT, N1);
n = [0 : N1-1]; figure('NumberTitle', 'off', 'Name', 'P5.16.1 x(n) & y(n)')
set(gcf,'Color','white');
subplot(3,1,1); stem(n, xn);
xlabel('n'); ylabel('x(n)');
title('x(n), IDFT of X(k)'); grid on;
subplot(3,1,2); stem(n, yn1);
xlabel('n'); ylabel('y(n)');
title('y(n) by circular shift x((n-5))_N N=10'); grid on;
subplot(3,1,3); stem(n, yn2);
xlabel('n'); ylabel('y(n)');
title('y(n) by IDFT of Y(k)'); grid on;
运行结果:
代码:
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.16 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % -------------------------------------------------------------------------------
% X(k) and Y(k) both 10-point DFTs of x(n) and y(n) respectively
% X(k) = exp(j0.2pi*k) k=[0:9]
% 3 y(n) = x((3-n))10
% ------------------------------------------------------------------------------- k1 = [0:9];
Xk_DFT = exp(j*0.2*pi*k1);
N1 = length(Xk_DFT); % length is 10 magXk_DFT = abs( [ Xk_DFT ] ); % DFT magnitude
angXk_DFT = angle( [Xk_DFT] )/pi; % DFT angle
realXk_DFT = real(Xk_DFT); imagXk_DFT = imag(Xk_DFT); figure('NumberTitle', 'off', 'Name', 'P5.16.3 DFT(k) of x(n)')
set(gcf,'Color','white');
subplot(2,1,1); stem(k1, magXk_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('magnitude(k)');
title('DFT magnitude of x(n), N=10'); grid on;
subplot(2,1,2); stem(k1, angXk_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('angle(k)');
title('DFT angle of x(n), N=10'); grid on; [xn] = real(idft(Xk_DFT, N1));
n = [0 : N1-1]; % +++++++++++++++++++++++++++++++++++++++++++++++++++++++
% 1st way to get y(n)-----circular shifft
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++
xn_cirfold = xn(mod(-n,N1)+1);
m = 3; % shift
yn1 = cirshftt(xn_cirfold, m, length(xn)); % +++++++++++++++++++++++++++++++++++++++++++++++++++++++
% 2ed way to get y(n)-----IDFT of Y(k)
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++
k1 = [0:9];
Yk_DFT = exp(j*2*pi*(10-4*k1)/10);
N1 = length(Yk_DFT); % length is 10 magYk_DFT = abs( [ Yk_DFT ] ); % DFT magnitude
angYk_DFT = angle( [Yk_DFT] )/pi; % DFT angle
realYk_DFT = real(Yk_DFT); imagYk_DFT = imag(Yk_DFT); figure('NumberTitle', 'off', 'Name', 'P5.16.3 DFT(k) of y(n)')
set(gcf,'Color','white');
subplot(2,1,1); stem(k1, magYk_DFT);
xlabel('k'); ylabel('magnitude(k)');
title('DFT magnitude of y(n), N=10'); grid on;
subplot(2,1,2); stem(k1, angYk_DFT);
xlabel('k'); ylabel('angle(k)');
title('DFT angle of y(n), N=10'); grid on; [yn2] = real(idft(Yk_DFT, N1));
n = [0 : N1-1]; figure('NumberTitle', 'off', 'Name', 'P5.16.3 x(n) & y(n)')
set(gcf,'Color','white');
subplot(3,1,1); stem(n, xn);
xlabel('n'); ylabel('x(n)');
title('x(n), IDFT of X(k)'); grid on;
subplot(3,1,2); stem(n, yn1);
xlabel('n'); ylabel('y(n)');
title('y(n) by circular shift x((3-n))_N N=10'); grid on;
subplot(3,1,3); stem(n, yn2);
xlabel('n'); ylabel('y(n)');
title('y(n) by IDFT of Y(k)'); grid on;
运行结果:
X(k)的图见第1小题,这里不附了。
《DSP using MATLAB》Problem5.16的更多相关文章
- 《DSP using MATLAB》Problem5.33
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem5.23
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% O ...
- 《DSP using MATLAB》示例Example7.25
今天清明放假的第二天,早晨出去吃饭时天气有些阴,十点多开始“清明时节雨纷纷”了. 母亲远在他乡看孙子,挺劳累的.父亲照顾生病的爷爷…… 我打算今天把<DSP using MATLAB>第7 ...
- 《DSP using MATLAB》Problem 7.16
使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 4.16
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》Problem 2.16
先由脉冲响应序列h(n)得到差分方程系数,过程如下: 代码: %% ------------------------------------------------------------------ ...
- 《DSP using MATLAB》 示例 Example 9.16
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》示例Example 8.16
%% ------------------------------------------------------------------------ %% Output Info about thi ...
- 《DSP using MATLAB》Problem 7.26
注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...
随机推荐
- ubuntu compile openjdk87
0. use oracle JDK,not OpenJDK 1. 遇到错误Error:./gamma: relocation error: /usr/lib/jvm/java-7-openjdk-am ...
- Python Django 之 直接执行自定义SQL语句(一)
一.执行自定义SQL方法 1.Executing custom SQL directly 直接执行自定义SQL,这种方式可以完全避免数据模型,而是直接执行原始的SQL语句. 2.Manage ...
- JDBC:随机生成车牌号,批量插入数据库
package InsertTest; /* * 单客户端:批量插入 */ import java.sql.Connection; import java.sql.DriverManager; imp ...
- VSTO:使用C#开发Excel、Word【9】
文件背后的代码VSTO支持文档背后的代码,要求开发人员使用VSTO项目中生成的具有预连接上下文和预连接事件的类.这些类有时被称为“代码后面”类,因为它们是与特定文档或工作表相关联的代码.在Word中, ...
- netcore 2.0 部署 到iis
.net Core2.0应用程序发布window服务器报错容易错过的配置. 1.应用程序发布. 2.IIS上新建网站. 3.应用程序池选择无托管代码. 4.服务器上安装DotNetCore.1.0.2 ...
- ubuntu下修改文件权限
参考:https://www.cnblogs.com/viviwind/archive/2012/08/02/2619451.html 常用方法如下: sudo chmod 600 ××× (只有所有 ...
- Windows下安装Tensorflow报错 “DLL load failed:找不到指定的模块"
Windows下安装完tensorflow后,在cmd下运行python后import tensorflow出现如下错误: Traceback (most recent call last): Fi ...
- elk之logstash
环境: centos7 jdk8 1.创建Logstash源 rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch touch ...
- [Spring] Spirng中的AOP进行事务的传播属性和事务隔离级别
通知注解 前置通知(@Before):在某连接点(join point)之前执行的通知,但这个通知不能阻止连接点前的执行(除非它抛出一个异常) 返回后通知(@AfterReturning):在某连接点 ...
- [AOP] 之让人一脸蒙哔的面向切面编程
最近接触到了面向切面编程,看来很多的文档,算是有一点点了解了,趁自己还有点印象,先把它们给写出来 什么是AOP AOP(Aspect-Oriented Programming), 即 面向切面编程. ...