《DSP using MATLAB》Problem 5.11
代码:
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.11 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % --------------------------------------------------------------
% 1 h(n) = [0.9^n] n=[0:5]
% -------------------------------------------------------------- nn1 = [0:5];
hh1 = 0.9 .^ nn1;
NN1 = length(hh1); % length is 6 %m = mod_1(nn1, NN1);
h = [hh1 zeros(1, 2)]; % padding zeros
n = [nn1 max(nn1)+1:max(nn1)+2]; figure('NumberTitle', 'off', 'Name', 'P5.11.1 Causal Real LSI h(n)')
set(gcf,'Color','white');
subplot(2,1,1); stem(nn1, hh1);
xlabel('n'); ylabel('h(n)');
title('h(n)=0.9^n ori sequence'); grid on;
subplot(2,1,2); stem(n, h);
xlabel('n'); ylabel('h(n)');
title('h(n) padding zeros'); grid on; %% =============================================================================
%% DTFT H(w) of hn sequence, w=[0:2pi],
%% =============================================================================
MM = 500;
[Hw_DTFT, w] = dtft1(h, n, MM); magHw_DTFT = abs(Hw_DTFT); angHw_DTFT = angle(Hw_DTFT)/pi;
realHw_DTFT = real(Hw_DTFT); imagHw_DTFT = imag(Hw_DTFT); %% --------------------------------------------------------------
%% START H_DTFT's mag ang real imag
%% --------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'P5.11.1 H(w) DTFT of h(n)');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magHw_DTFT); grid on; % axis([-2,2,0,15]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |H\_DTFT|');
subplot(2,2,3); plot(w/pi, angHw_DTFT); grid on; % axis([-2,2,-1,1]);
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Rad \pi'); %axis([-200,200,0,2]); subplot('2,2,2'); plot(w/pi, realHw_DTFT); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w/pi, imagHw_DTFT); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary');
%% --------------------------------------------------------------
%% END H_DTFT's mag ang real imag
%% -------------------------------------------------------------- %% ------------------------------------------------------------------
%% DFT(k) of hn sequence, k=[0:N-1]
%% w=2pi*k/N k=Nw/(2pi)
%% ------------------------------------------------------------------
N1 = length(h);
k1 = [0 : N1-1];
%k2 = [-N : N-1];
%k3 = [-N/2 : N/2];
Hk_DFT = dft(h, N1); % DFT
magHk_DFT = abs( Hk_DFT ) % DFT magnitude
angHk_DFT = angle( Hk_DFT )/pi % DFT angle
realHk_DFT = real(Hk_DFT); imagHk_DFT = imag(Hk_DFT); figure('NumberTitle', 'off', 'Name', 'P5.11.1 DFT(k) of h(n)')
set(gcf,'Color','white');
subplot(2,1,1); stem(k1, magHk_DFT); hold on; plot(N1*w/(2*pi), magHw_DTFT,'r--'); hold off;
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('magnitude(k)');
title('DFT magnitude of h(n), N=8'); grid on;
subplot(2,1,2); stem(k1, angHk_DFT); hold on; plot(N1*w/(2*pi), angHw_DTFT,'r--'); hold off;
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('angle(k)');
title('DFT angle of h(n), N=8'); grid on;
运行结果:
只会第1小题。
8点DFT基本能反映DTFT的幅度谱,但相位谱感觉稍有欠缺。
第2小题不会做。
《DSP using MATLAB》Problem 5.11的更多相关文章
- 《DSP using MATLAB》Problem 7.11
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 6.11
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 4.11
代码: %% ---------------------------------------------------------------------------- %% Output Info a ...
- 《DSP using MATLAB》Problem 8.11
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》Problem 7.16
使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.6
代码: 子函数ampl_res function [Hr,w,P,L] = ampl_res(h); % % function [Hr,w,P,L] = Ampl_res(h) % Computes ...
- 《DSP using MATLAB》Problem 5.21
证明: 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 5.20
窗外的知了叽叽喳喳叫个不停,屋里温度应该有30°,伏天的日子难过啊! 频率域的方法来计算圆周移位 代码: 子函数的 function y = cirshftf(x, m, N) %% -------- ...
- 《DSP using MATLAB》Problem 5.14
说明:这两个小题的数学证明过程都不会,欢迎博友赐教. 直接上代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
随机推荐
- 【1】windows下IOS开发基础环境搭建
一.目的 本文的目的是windows下IOS开发基础环境搭建做了对应的介绍,大家可根据文档步骤进行mac环境部署: 二.安装虚拟机 下载虚拟机安装文件绿色版,点击如下文件安装 获取安装包: ...
- UVALive 3401 - Colored Cubes 旋转 难度: 1
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- django_rq无法监听两个队列问题
django_rq是为django集成redis队列,这个用的少,一般会选择celery,没办法项目中用到了.用起来很简单,配置可以参考官方文档:https://pypi.org/project/dj ...
- nginx+vue刷新404
问题原因:刷新页面时访问的资源在服务端找不到,因为vue-router设置的路径不是真实存在的路径.如上的404现象,是因为在nginx配置的根目录/Data/app/xqsj_wx/dist下面压根 ...
- RabbitMQ 简单的消息发送与接收
RabbitMQ是建立在AMQP(Advanced Message Queuing Protocol,高级消息队列协议)基础上的,而AMQP是建立在TCP协议之上的. 因此,RabbitMQ是需要建立 ...
- vue-1-模板语法
文本 <span>Message: {{ msg }}</span><span v-once>这个将不会改变: {{ msg }}</span> 原始 ...
- 踩坑 net core
webclient 可以替换为 HttpClient 下载获取url的内容: 证书: https://stackoverflow.com/questions/40014047/add-client ...
- format格式
The format part is where you can specify more precisely the format of the data that you expect. For ...
- Aizu - 2681(括号匹配)
Problem Statement You are given nn strings str1,str2,…,strnstr1,str2,…,strn, each consisting of ( an ...
- Mybaties学习
基于现在Mybatis 我没有学习太多,就基于简单的增删改查进行基础学习. 学习资源来自 http://www.cnblogs.com/xdp-gacl/p/4261895.html 1 引入 ...