《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,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...
随机推荐
- sql2008r2安装失败的解决办法
setup fails with: '.', hexadecimal value 0x00, is an invalid character.SQL 2012 Setup issues - hexad ...
- POJ 3436 ACM Computer Factory 最大流,拆点 难度:1
题目 http://poj.org/problem?id=3436 题意 有一条生产线,生产的产品共有p个(p<=10)零件,生产线上共有n台(n<=50)机器,每台机器可以每小时加工Qi ...
- JAVA项目之苹果IAP内购JAVA服务器验证流程详解
1.前言 本博客是经历过多个项目检验的, 绝对真实, 适应于对苹果iap内购稍微有些了解的JAVA开发人员, 认真看, 定能完美解决苹果内购问题. 苹果IAP内购支付实际上是"将客户端支 ...
- MySQL字符集与校对
一.什么是字符集与校对 1.字符集与校对 字符集是指一种从二进制编码到某种字符符号的映射. 校队是指一组用于某个字符集的配许规则. 2.utf8与utf8mb4 标准的UTF-8字符集编码是可以使用1 ...
- sys.argv]的用法
Python中 sys.argv[]的用法简明解释 因为是看书自学的python,开始后不久就遇到了这个引入的模块函数,且一直在IDLE上编辑了后运行,试图从结果发现它的用途,然而结果一直都是没结果, ...
- Cracking The Coding Interview3.3
//Imagine a (literal) stack of plates. If the stack gets too high, it might topple. Therefore, in re ...
- Win10安装mysql-8.0.11-winx64详细步骤
安装 mysql-8.0.11-winx64 https://blog.csdn.net/qq_20788055/article/details/80372577
- Centos7下mysql5.7.22主从配置
一:服务器配置 1.1修改root密码: ALTER USER 'root'@'localhost' IDENTIFIED BY 'xxxx'; 1.2添加远程登陆用户: GRANT ALL PRIV ...
- spring相关jar包的作用讲解(转)
Spring各个jar包作用 原文链接:https://www.cnblogs.com/1995hxt/p/5255210.html Spring AOP:Spring的面向切面编程,提供AOP ...
- PAT 乙级 1066. 图像过滤(15)
图像过滤是把图像中不重要的像素都染成背景色,使得重要部分被凸显出来.现给定一幅黑白图像,要求你将灰度值位于某指定区间内的所有像素颜色都用一种指定的颜色替换. 输入格式: 输入在第一行给出一幅图像的分辨 ...