上代码:

x1 = rand(1,11); x2 = rand(1,11); n = 0:10;
alpha = 2; beta = 3; k = 0:500;
w = (pi/500)*k; % [0,pi] axis divided into 501 points. X1 = x1 * (exp(-j*pi/500)) .^ (n'*k); % DTFT of x1
X2 = x2 * (exp(-j*pi/500)) .^ (n'*k); % DTFT of x2 x = alpha * x1 + beta * x2; % Linear combination of x1 & x2
X = x * (exp(-j*pi/500)) .^ (n'*k); % DTFT of x magX1 = abs(X1); angX1 = angle(X1); realX1 = real(X1); imagX1 = imag(X1);
magX2 = abs(X2); angX2 = angle(X2); realX2 = real(X2); imagX2 = imag(X2);
magX = abs(X); angX = angle(X); realX = real(X); imagX = imag(X); %verification
X_check = alpha*X1 + beta*X2; % Linear combination of X1 & X2
error = max(abs(X-X_check)); % Difference %% --------------------------------------------------------------
%% START X1's mag ang real imag
%% --------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'X1 its Magnitude and Angle, Real and Imaginary Part');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magX1); grid on; % axis([-2,2,0,15]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |X1|');
subplot(2,2,3); plot(w/pi, angX1/pi); grid on; % axis([-2,2,-1,1]);
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); subplot('2,2,2'); plot(w/pi, realX1); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w/pi, imagX1); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary');
%% --------------------------------------------------------------
%% END X1's mag ang real imag
%% -------------------------------------------------------------- %% --------------------------------------------------------------
%% START X2's mag ang real imag
%% --------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'X2 its Magnitude and Angle, Real and Imaginary Part');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magX2); grid on; % axis([-2,2,0,15]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |X2|');
subplot(2,2,3); plot(w/pi, angX2/pi); grid on; % axis([-2,2,-1,1]);
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); subplot('2,2,2'); plot(w/pi, realX2); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w/pi, imagX2); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary');
%% --------------------------------------------------------------
%% END X2's mag ang real imag
%% -------------------------------------------------------------- %% --------------------------------------------------------------
%% 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([-2,2,0,15]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |X|');
subplot(2,2,3); plot(w/pi, angX/pi); grid on; % axis([-2,2,-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
%% --------------------------------------------------------------

结果:

  

DSP using MATLAB 示例Example3.7的更多相关文章

  1. 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 ...

  2. DSP using MATLAB 示例 Example3.19

    代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signa ...

  3. DSP using MATLAB示例Example3.18

    代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Continuous-time Fou ...

  4. 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 ...

  5. 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, ...

  6. 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 ...

  7. DSP using MATLAB 示例Example3.17

  8. DSP using MATLAB 示例 Example3.15

    上代码: subplot(1,1,1); b = 1; a = [1, -0.8]; n = [0:100]; x = cos(0.05*pi*n); y = filter(b,a,x); figur ...

  9. DSP using MATLAB 示例 Example3.13

    上代码: w = [0:1:500]*pi/500; % freqency between 0 and +pi, [0,pi] axis divided into 501 points. H = ex ...

  10. 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 , ...

随机推荐

  1. SSH框架中json传递失败

    错误截图: 这个错误乍一看无从下手,报的都是框架底层的错误,于是查阅资料得到了答案. 错误原因:struts会将action中定义的一些变量序列化转换成json格式,需要调用对象的一系列get方法,并 ...

  2. iOS - UIButton设置图片文字上图下文排列

    经查阅资料及尝试,最终解决了在图片和文字垂直排列的情况下,如果文字长度变化会导致图片位置变动的问题,最开始采用了网上比较多的做法,做法如下: @interface UIButton (UIButton ...

  3. 三、jQuery--jQuery基础--jQuery基础课程--第8章 jQuery 实现Ajax应用

    1.使用load()方法异步请求数据 使用load()方法通过Ajax请求加载服务器中的数据,并把返回的数据放置到指定的元素中,它的调用格式为:load(url,[data],[callback]) ...

  4. EF – 5.DbSet与DbContext,数据更新奥秘

    5.6.4 <DbSet与DbContext> 介绍DbSet与DbContext中的核心属性及重要方法. 5.6.5 <数据更新的奥秘>  这一讲极为重要,因为它揭示出了En ...

  5. PHP获取远程图片并调整图像大小(转)

    <?php /** * *函数:调整图片尺寸或生成缩略图 *修改:2013-2-15 *返回:True/False *参数: * $Image 需要调整的图片(含路径) * $Dw=450 调整 ...

  6. Logcat打印调试信息

    Android Logcat调试中的V.D.I.W.E的分别代表什么? Log.v -- 黑色 -- verbose infoLog.d -- 蓝色 -- debug infoLog.i -- 绿色 ...

  7. Delphi按下F1不能出现帮助文档的解决方法

    不光是Delphi,Windows里面所有的之所以无法打开.hlp帮助文档的问题都可以使用以下的方法来解决 问题:情况是这样的,不是打不开hlp帮助文档,按F1出现的是Windows的帮助.而Delp ...

  8. OCJP(1Z0-851) 模拟题分析(一)11

    Exam : 1Z0-851 Java Standard Edition 6 Programmer Certified Professional Exam 以下分析全都是我自己分析或者参考网上的,定有 ...

  9. ArcGIS ElementLayer上放置Windows控件

    ElementLayer是ArcGIS API for Silverlight/WPF中的一种图层类型,主要用来承载Silverlight/WPF中的UIElement对象(UIElement),使用 ...

  10. CXF学习 (1)

    Axis(Apache) -> Axis2(Apache) XFire - > CXF (XFire+Celtrix) (Apache) CXF并不仅仅是Webservice框架,更号称是 ...