《DSP using MATLAB》Problem 2.7
1、代码:
function [xe,xo,m] = evenodd_cv(x,n)
%
% Complex signal decomposition into even and odd parts
% ----------------------------------------------------
% [xe,xo,m] = evenodd_cv(x,n)
%
%
%if any(imag(x) = 0)
% error('x is a real sequence');
%end m = -fliplr(n);
m1 = min([m,n]); m2 = max([m,n]); m = m1:m2; nm = n(1)-m(1); n1 = 1:length(n); x1 = zeros(1,length(m)); x1(n1+nm) = x; x = x1; xe = 0.5*(x + conj(fliplr(x))); xo = 0.5*(x - conj(fliplr(x)));
2、代码
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 2.7.2 \n\n'); [v, d] = version;
fprintf(' MATLAB Version: %20s\n\n', v);
fprintf(' Released Date: %17s\n\n', d); time_stamp = datestr(now, 31);
[wkd1, wkd2] = weekday(today, 'long');
fprintf(' Today is %7s, and Now is %20s \n\n', wkd2, time_stamp);
%% ------------------------------------------------------------------------ n = [0:10];
x = 10 * exp( (-0.1+j*0.2*pi) * n ); [xe,xo,m] = evenodd_cv(x,n); figure('NumberTitle', 'off', 'Name', 'Problem 2.7 x(n)')
set(gcf,'Color',[1,1,1]) % 改变坐标外围背景颜色
subplot(2,1,1); stem(n, real(x)); title('x sequence Real Part');
xlabel('n'); ylabel('Real[x(n)]') ;
% axis([-10,10,0,1.2])
grid on
subplot(2,1,2); stem(n, imag(x)); title('x sequence Imag Part');
xlabel('n'); ylabel('Imag[x(n)]');
grid on; figure('NumberTitle', 'off', 'Name', 'Problem 2.7 xe(m)')
set(gcf,'Color',[1,1,1])
subplot(2,1,1); stem(m,real(xe)); title('Real Part of Even Sequence');
xlabel('m'); ylabel('Real[xe(m)]');
%axis([-10,10,0,1.2])
grid on
subplot(2,1,2); stem(m,imag(xe)); title('Imag Part of Even Sequence');
xlabel('m'); ylabel('Imag[xe(m)]');
%axis([-10,10,0,1.2])
grid on figure('NumberTitle', 'off', 'Name', 'Problem 2.7 xo(m)')
set(gcf,'Color','white')
subplot(2,1,1); stem(m,real(xo)); title('Real Part of Odd Sequence');
xlabel('m'); ylabel('Real[xo(m)]');
%axis([-10,10,0,1.2])
grid on
subplot(2,1,2); stem(m,imag(xo)); title('Imag Part of Odd Sequence');
xlabel('m'); ylabel('Imag[xo(m)]');
%axis([-10,10,0,1.2])
grid on % -----------------------------------------
% xe(-m)
% -----------------------------------------
figure('NumberTitle', 'off', 'Name', 'Problem 2.7 xe(-m)')
set(gcf,'Color',[1,1,1])
subplot(2,1,1); stem(m,real(fliplr(xe))); title('Real Part of xe(-m)');
xlabel('m'); ylabel('Real[xe(-m)]');
%axis([-10,10,0,1.2])
grid on
subplot(2,1,2); stem(m,imag(fliplr(xe))); title('Imag Part of xe(-m)');
xlabel('m'); ylabel('Imag[xe(-m)]');
%axis([-10,10,0,1.2])
grid on % ------------------------------------------------------
% xo(-m)
% ------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Problem 2.7 xo(-m)')
set(gcf,'Color',[1,1,1])
subplot(2,1,1); stem(m,real(fliplr(xo))); title('Real Part of xo(-m)');
xlabel('m'); ylabel('Real[xo(-m)]');
grid on
subplot(2,1,2); stem(m,imag(fliplr(xo))); title('Imag Part of xo(-m)');
xlabel('m'); ylabel('Imag[xo(-m)]');
grid on
运行结果:
《DSP using MATLAB》Problem 2.7的更多相关文章
- 《DSP using MATLAB》Problem 7.27
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.26
注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.25
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.24
又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.23
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...
- 《DSP using MATLAB》Problem 7.16
使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.15
用Kaiser窗方法设计一个台阶状滤波器. 代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.14
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.13
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.12
阻带衰减50dB,我们选Hamming窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
随机推荐
- 77. Combinations(回溯)
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: I ...
- hdu5012 圆环相交面积
题中给了 两个同心圆, 一个大圆一个小圆,然后再给了一个大圆一个小圆也是同心圆,求这两个圆环相交的面积,用两个大圆面积减去两倍大小圆面积交加上两个小圆面积交,就ok了 这里算是坑明白了 使用acos的 ...
- ubuntu18.04下搭建深度学习环境anaconda2+ cuda9.0+cudnn7.0.5+tensorflow1.7【原创】【学习笔记】
PC:ubuntu18.04.i5.七彩虹GTX1060显卡.固态硬盘.机械硬盘 作者:庄泽彬(欢迎转载,请注明作者) 说明:记录在ubuntu18.04环境下搭建深度学习的环境,之前安装了cuda9 ...
- linux下递归删除指定后缀名的文件
以删除当前目录到所有子目录下的后缀名为rej的文件为例: find . -name "*.rej" |xargs rm -f
- String StringBuilder StringBuffer 对比 总结得非常好
转自:http://www.iteye.com/topic/522167 作者:每次上网冲杯Java时,都能看到关于String无休无止的争论.还是觉得有必要让这个讨厌又很可爱的String美眉,赤裸 ...
- POJ 3422 Kaka's Matrix Travels(拆点+最大费用流)题解
题意:小A从左上角走到右下角,每个格子都有一个价值,经过这个格子就把价值拿走,每次只能往下或往右走,问你走k次最多能拿多少价值的东西. 思路:这里有一个限制条件就是经过之后要把东西拿走,也就是每一格的 ...
- [QA翻译]如何在Storm里拆分stream流?
原文:http://stackoverflow.com/questions/19807395/how-would-i-split-a-stream-in-apache-storm 问题:我现在不清楚如 ...
- P4 PI库安装
repo:Github PI P4Runtime - a control plane framework and tools for the P4 programming language 这个是P4 ...
- 雷林鹏分享:Ruby Socket 编程
Ruby Socket 编程 Ruby提供了两个级别访问网络的服务,在底层你可以访问操作系统,它可以让你实现客户端和服务器为面向连接和无连接协议的基本套接字支持. Ruby 统一支持应用程的网络协议, ...
- Mybatis四种分页方式
数组分页 查询出全部数据,然后再list中截取需要的部分. mybatis接口 List<Student> queryStudentsByArray(); xml配置文件 <sele ...