DSP using MATLAB 示例 Example3.12

用到的性质

代码:
n = -5:10; x = sin(pi*n/2);
k = -100:100; w = (pi/100)*k; % freqency between -pi and +pi , [0,pi] axis divided into 101 points.
X = x * (exp(-j*pi/100)) .^ (n'*k); % DTFT of x % signal decomposition
[xe,xo,m] = evenodd(x,n); % even and odd parts
XE = xe * (exp(-j*pi/100)) .^ (m'*k); % DTFT of xe
XO = xo * (exp(-j*pi/100)) .^ (m'*k); % DTFT of xo magXE = abs(XE); angXE = angle(XE); realXE = real(XE); imagXE = imag(XE);
magXO = abs(XO); angXO = angle(XO); realXO = real(XO); imagXO = imag(XO);
magX = abs(X); angX = angle(X); realX = real(X); imagX = imag(X); %verification
XR = real(X); % real part of X
error1 = max(abs(XE-XR)); % Difference
XI = imag(X); % imag part of X
error2 = max(abs(XO-j*XI)); % Difference figure('NumberTitle', 'off', 'Name', 'x sequence')
set(gcf,'Color','white');
stem(n,x); title('x sequence'); xlabel('n'); ylabel('x(n)'); grid on; figure('NumberTitle', 'off', 'Name', 'xe & xo sequence')
set(gcf,'Color','white');
subplot(2,1,1); stem(m,xe); title('xe sequence '); xlabel('m'); ylabel('xe(m)'); grid on;
subplot(2,1,2); stem(m,xo); title('xo sequence '); xlabel('m'); ylabel('xo(m)'); grid on; %% --------------------------------------------------------------------
%% START X's mag ang real imag
%% --------------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'X its Magnitude and Angle, Real and Imaginary Part');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magX); grid on; axis([-1,1,0,9]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |X|');
subplot(2,2,3); plot(w/pi, angX/pi); grid on; axis([-1,1,-1,1]);
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); subplot('2,2,2'); plot(w/pi, realX); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w/pi, imagX); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary');
%% -------------------------------------------------------------------
%% END X's mag ang real imag
%% ------------------------------------------------------------------- %% --------------------------------------------------------------
%% START XE's mag ang real imag
%% --------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'XE its Magnitude and Angle, Real and Imaginary Part');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magXE); grid on; axis([-1,1,0,2]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |XE|');
subplot(2,2,3); plot(w/pi, angXE/pi); grid on; axis([-1,1,-1,1]);
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); subplot('2,2,2'); plot(w/pi, realXE); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w/pi, imagXE); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary'); %% --------------------------------------------------------------
%% END XE's mag ang real imag
%% -------------------------------------------------------------- %% --------------------------------------------------------------
%% START XO's mag ang real imag
%% --------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'XO its Magnitude and Angle, Real and Imaginary Part');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magXO); grid on; axis([-1,1,0,8]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |XO|');
subplot(2,2,3); plot(w/pi, angXO/pi); grid on; axis([-1,1,-1,1]);
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); subplot('2,2,2'); plot(w/pi, realXO); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w/pi, imagXO); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary'); %% --------------------------------------------------------------
%% END XO's mag ang real imag
%% -------------------------------------------------------------- %% ----------------------------------------------------------------
%% START Graphical verification
%% ----------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Graphical verification');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,XR); grid on; axis([-1,1,-2,2]);
xlabel('frequency in \pi units'); ylabel('Re(X)'); title('Real Part of X ');
subplot(2,2,2); plot(w/pi,XI); grid on; axis([-1,1,-10,10]);
xlabel('frequency in \pi units'); ylabel('Im(X)'); title('Imaginary Part of X '); subplot(2,2,3); plot(w/pi,realXE); grid on; axis([-1,1,-2,2]);
xlabel('frequency in \pi units'); ylabel('XE'); title('Transform of even part ');
subplot(2,2,4); plot(w/pi,imagXO); grid on; axis([-1,1,-10,10]);
xlabel('frequency in \pi units'); ylabel('XO'); title('Transform of odd part'); %% ----------------------------------------------------------------
%% END Graphical verification
%% ----------------------------------------------------------------
运行结果:






DSP using MATLAB 示例 Example3.12的更多相关文章
- DSP using MATLAB 示例Example3.21
代码: % Discrete-time Signal x1(n) % Ts = 0.0002; n = -25:1:25; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*a ...
- DSP using MATLAB 示例 Example3.19
代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signa ...
- DSP using MATLAB示例Example3.18
代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Continuous-time Fou ...
- DSP using MATLAB 示例Example3.23
代码: % Discrete-time Signal x1(n) : Ts = 0.0002 Ts = 0.0002; n = -25:1:25; nTs = n*Ts; x1 = exp(-1000 ...
- DSP using MATLAB示例Example3.16
代码: b = [0.0181, 0.0543, 0.0543, 0.0181]; % filter coefficient array b a = [1.0000, -1.7600, 1.1829, ...
- DSP using MATLAB 示例 Example3.11
用到的性质 上代码: n = -5:10; x = rand(1,length(n)); k = -100:100; w = (pi/100)*k; % freqency between -pi an ...
- DSP using MATLAB 示例 Example3.10
用到的性质 上代码: n = -5:10; x = rand(1,length(n)) + j * rand(1,length(n)); k = -100:100; w = (pi/100)*k; % ...
- DSP using MATLAB 示例Example3.22
代码: % Discrete-time Signal x2(n) Ts = 0.001; n = -5:1:5; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*abs(nT ...
- DSP using MATLAB 示例Example3.17
随机推荐
- Gson解析复杂的json数据
最近在给公司做一个直播APK的项目,主要就是通过解析网络服务器上的json数据,然后将频道地址下载下来再调用Android的播放器进行播放,原先本来打算使用普通的json解析方法即JsonObject ...
- 【OpenCV】内存溢出
今天在写读大量图片时,发现在读到第721张时,内存溢出了,无法继续读.出错语句为pframe2 = cvLoadImage(pname2); 后来加上了ReleaseImage(&pname2 ...
- 如何将.il、.res文件封装成dll文件
将你的.il..res文件保存在你的硬盘上,如下图: 我存放的路径在E盘的test文件夹中,我们开始封装了咯.进入DOS命令,如下图: 我们通过DOS命令先进入.il..res文件目录,如下图: 然后 ...
- <context-param>与<init-param>
<context-param>的作用: web.xml的配置中<context-param>配置作用1. 启动一个WEB项目的时候,容器(如:Tomcat)会去读它的配置文件w ...
- Qt 添加启动项
QString application_name = QApplication::applicationName(); QSettings *settings = new QSettings(&quo ...
- [Android Pro] Dangerous permissions and permission groups.
Permission Group Permissions CALENDAR READ_CALENDAR WRITE_CALENDAR CAMERA CAMERA CONTACTS READ_CONTA ...
- oracle 监控
sqlplus "/as sysdba" .监控当前数据库谁在运行什么SQL语句 SELECT osuser, username, sql_text from v$session ...
- 转载_虚拟机下LInux(终端)配置网络的方法
出自: http://www.360doc.com/content/14/1027/11/17496895_420258403.shtml 对文章的重点进行剪贴,方便查看. 这几天在虚拟机vmware ...
- [译] 用 Swift 创建自定义的键盘
本文翻译自 How to make a custom keyboard in iOS 8 using Swift 我将讲解一些关于键盘扩展的基本知识,然后使用iOS 8 提供的新应用扩展API来创建一 ...
- 001课-java_web开发入门
一.Tomcat服务器常见启动问题:(1).Java_home环境变量,由于tomcat服务器的bin目录中的一些jar文件必须使用到java类库,所以必须先配置Java_home环境变量.(2).端 ...